Registry / phosphor-react-native

phosphor-react-native

JSON →
library3.0.4jsnpmunverified

Phosphor React Native is a library providing a flexible, open-source icon family for React Native applications, compatible with both iOS and Android platforms. The current stable version is 3.0.4, with releases occurring semi-regularly, typically every few months for minor updates or bug fixes, and major versions (like v3.0.0) introducing breaking changes less frequently. Key differentiators include its extensive collection of icons available in six distinct weights (thin, light, regular, bold, fill, duotone), robust TypeScript support, efficient tree-shaking to minimize bundle size, and a powerful React Context API for applying global styling configurations. It's heavily inspired by the web-focused `phosphor-react` library, bringing the same aesthetic and functionality to the React Native ecosystem.

npm install phosphor-react-native
INSTALL
IMPORT
SIG · PHOSPHOR-REACT-NAT
P
phosphor-react-native
javascriptv3.0.4
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

HeartIcon
import { HeartIcon } from 'phosphor-react-native';
import Heart from 'phosphor-react-native/Heart'; import { Heart } from 'phosphor-react-native';
Since v3.0.0, all icon components are named with an 'Icon' suffix and are named exports. Default exports were removed.
IconContext
import { IconContext } from 'phosphor-react-native';
const { IconContext } = require('phosphor-react-native');
Used for providing global icon styling via React Context. CommonJS `require` generally hinders tree-shaking.
IconProps
import type { IconProps } from 'phosphor-react-native';
import { IconProps } from 'phosphor-react-native';
Type definition for icon component props. Use `import type` for clarity and bundler optimization when importing only types.

Demonstrates basic icon usage, custom styling with individual props, and global styling via `IconContext.Provider`.

import React from 'react'; import { View, StyleSheet } from 'react-native'; import { IconContext, HorseIcon, HeartIcon, CubeIcon } from 'phosphor-react-native'; const App = () => { return ( <IconContext.Provider value={{ color: 'limegreen', size: 32, weight: 'bold' }} > <View style={styles.container}> {/* Inherits context values: limegreen, 32px, bold */} <HorseIcon /> {/* Overrides context: uses #AE2983, 32px, fill */} <HeartIcon color="#AE2983" weight="fill" size={32} /> {/* Overrides context: uses teal, 32px, duotone */} <CubeIcon color="teal" weight="duotone" /> </View> </IconContext.Provider> ); }; const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', flexDirection: 'row', gap: 20, backgroundColor: '#f0f0f0' } }); export default App;
Debug
Known issues
breakingVersion 3.0.0 introduced significant breaking changes: default exports for all icons were removed, and all exported icon components are now suffixed with 'Icon'. For example, an icon previously imported as `Heart` is now `HeartIcon`.
fix
Update all icon imports from `import Heart from 'phosphor-react-native/Heart';` or `import { Heart } from 'phosphor-react-native';` to `import { HeartIcon } from 'phosphor-react-native';`.
affects: >=3.0.0
gotchaThis library has a required peer dependency on `react-native-svg` for rendering SVG icons. Without it, icons will not display correctly and may lead to runtime errors or crashes.
fix
Ensure `react-native-svg` is installed in your project: `yarn add react-native-svg` or `npm install --save react-native-svg`. Follow `react-native-svg`'s linking instructions if necessary for older React Native versions.
affects: >=1.0.0
gotchaTypeScript users might encounter errors like `Property 'className' does not exist on type '...'` when attempting to pass a `className` prop directly to icons or `Svg` components.
fix
Add the following type augmentation to your `global.d.ts` file or a similar declaration file in your project:
```ts
import type { SvgProps as DefaultSvgProps } from 'react-native-svg';

declare module 'react-native-svg' {
  interface SvgProps extends DefaultSvgProps {
    className?: string;
  }
}
declare module 'phosphor-react-native' {
  interface IconProps extends DefaultIconProps {
    className?: string;
  }
}
```
affects: >=1.0.0
Errors
Common errors & fixes
Property 'className' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Svg> & Pick<Readonly<SvgProps>, "children" | "style" | ... 144 more ... | "fontVariationSettings"> & InexactPartial<...> & InexactPartial<...>'.
The TypeScript compiler indicates that the `className` prop is not defined on the `SvgProps` or `IconProps` interfaces by default within `react-native-svg` or `phosphor-react-native`.
fix
Apply the type augmentation provided in the `Warnings` section to your project's `global.d.ts` or a similar type declaration file.
Invariant Violation: requireNativeComponent: "RNSVGPath" was not found in the UIManager.
The `react-native-svg` library, a peer dependency for `phosphor-react-native`, is either not installed or not correctly linked with your React Native project.
fix
Install `react-native-svg` (`yarn add react-native-svg` or `npm install --save react-native-svg`) and ensure it is properly configured and linked according to its documentation, especially for older React Native versions that may require manual linking.
Upgrade
Version history
3.0.4latest on npm
Audit
Dependencies
reactrequiredReact Native core dependency.
react-nativerequiredReact Native core dependency.
react-native-svgrequiredRequired for rendering SVG icons in React Native.
Agent activity
2 hits · last 30 days
node
2
Resources
phosphor-react-native — npm install phosphor-react-native · libregistry