Gathering detailed insights and metrics for phosphor-react-native
Gathering detailed insights and metrics for phosphor-react-native
phosphor-icons for react-native. A flexible icon family for React Native
npm install phosphor-react-native
Typescript
Module System
Node Version
NPM Version
TypeScript (73.61%)
JavaScript (26.39%)
Total Downloads
696,278
Last Day
2,010
Last Week
8,685
Last Month
37,978
Last Year
399,321
204 Stars
57 Commits
26 Forks
6 Watching
4 Branches
7 Contributors
Minified
Minified + Gzipped
Latest Version
2.3.1
Package Id
phosphor-react-native@2.3.1
Unpacked Size
21.90 MB
Size
2.65 MB
File Count
18,167
NPM Version
11.0.0
Node Version
23.6.0
Publised On
25 Jan 2025
Cumulative downloads
Total Downloads
Last day
-0.5%
2,010
Compared to previous day
Last week
-12.6%
8,685
Compared to previous week
Last month
-13.7%
37,978
Compared to previous month
Last year
103.8%
399,321
Compared to previous year
3
33
Phosphor is a flexible icon family for interfaces, diagrams, presentations — whatever, really. Explore all our icons at phosphoricons.com. Inspired by phosphor-react.
1yarn add phosphor-react-native
or
1npm install --save phosphor-react-native
Simply import the icons you need, and add them anywhere in your render method. Phosphor supports tree-shaking, so your bundle only includes code for the icons you use.
1import React from 'react'; 2import { View } from 'react-native'; 3import { Horse, Heart, Cube } from 'phosphor-react-native'; 4 5const App = () => { 6 return ( 7 <View> 8 <Horse /> 9 <Heart color="#AE2983" weight="fill" size={32} /> 10 <Cube color="teal" weight="duotone" /> 11 </View> 12 ); 13};
If you get this error...
Property 'className' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Svg> & Pick<Readonly<SvgProps>, "children" | "style" | ... 144 more ... | "fontVariationSettings"> & InexactPartial<...> & InexactPartial<...>'
Add this code to your global.d.ts
file
1import type { SvgProps as DefaultSvgProps } from 'react-native-svg'; 2 3declare module 'react-native-svg' { 4 interface SvgProps extends DefaultSvgProps { 5 className?: string; 6 } 7}
Icon components accept all props that you can pass to a normal SVG element, including inline style
objects, onClick
handlers, and more. The main way of styling them will usually be with the following props:
string
– Icon stroke/fill color. Can be any CSS color string, including hex
, rgb
, rgba
, hsl
, hsla
, named colors.number | string
– Icon height & width. As with standard React elements, this can be a number, or a string with units in px
, %
, em
, rem
, pt
, cm
, mm
, in
."thin" | "light" | "regular" | "bold" | "fill" | "duotone"
– Icon weight/style. Can also be used, for example, to "toggle" an icon's state: a rating component could use Stars with weight="regular"
to denote an empty star, and weight="fill"
to denote a filled star.boolean
– Flip the icon horizontally. Can be useful in RTL languages where normal icon orientation is not appropriate.string
– Accessibility labelstring
– Accessibility label IDstring
– testID for testsstring
– Duotone fill color. Can be any CSS color string, including hex
, rgb
, rgba
, hsl
, hsla
, named colors. Default value to black.number
– The opacity of the duotoneColor. Default value to 0.2.Phosphor takes advantage of React Context to make applying a default style to all icons simple. Create an IconContext.Provider
at the root of the app (or anywhere above the icons in the tree) and pass in a configuration object with props to be applied by default to all icons:
1import React from 'react'; 2import { View } from 'react-native'; 3import { IconContext, Horse, Heart, Cube } from 'phosphor-react-native'; 4 5const App = () => { 6 return ( 7 <IconContext.Provider 8 value={{ 9 color: 'limegreen', 10 size: 32, 11 weight: 'bold', 12 }} 13 > 14 <View> 15 <Horse /> {/* I'm lime-green, 32px, and bold! */} 16 <Heart /> {/* Me too! */} 17 <Cube /> {/* Me three :) */} 18 </View> 19 </IconContext.Provider> 20 ); 21};
You may create multiple Contexts for styling icons differently in separate regions of an application; icons use the nearest Context above them to determine their style.
You may wish to import all icons at once for use in your project, though depending on your bundler this could prevent tree-shaking and make your app's bundle larger.
1import * as Icon from "phosphor-react-native"; 2... 3<Icon.Smiley /> 4<Icon.Folder weight="thin" /> 5<Icon.BatteryHalf size="24px" /> 6<Icon.AirplaneTakeoff size="24px" mirrored={true} />
In cases where tree shaking does not work (resulting in large bundle size), you can import icons individually in this format:
1// Javascript 2import Star from "phosphor-react-native/lib/commonjs/icons/Star"; 3 4// Typescript 5import Star from 'phosphor-react-native/src/icons/Star'; 6 7<Star size="24px" />
MIT
No vulnerabilities found.
No security vulnerabilities found.