Top Related Projects
Simply beautiful open-source icons
The iconic SVG, font, and CSS toolkit
Premium hand-crafted icons built by Ionic, for Ionic apps and web apps everywhere 🌎
A scalable set of icons handcrafted with <3 by GitHub
A set of over 5500 free MIT-licensed high-quality SVG icons for you to use in your web projects.
Material Design icons by Google (Material Symbols)
Quick Overview
Phosphor Icons React is a flexible icon family for React applications. It provides a comprehensive set of clean, consistent icons as React components, allowing easy integration and customization in React projects.
Pros
- Large collection of over 6,000 icons in various styles
- Easy to use and customize with React components
- Supports dynamic icon properties like size, color, and weight
- Regular updates and active maintenance
Cons
- Limited to React applications only
- May increase bundle size if many icons are imported
- Requires additional setup compared to using SVG files directly
- Some advanced customizations might require additional CSS
Code Examples
- Basic usage of an icon:
import { Heart } from "@phosphor-icons/react";
function MyComponent() {
return <Heart />;
}
- Customizing icon properties:
import { Envelope } from "@phosphor-icons/react";
function CustomIcon() {
return <Envelope size={32} color="#3b82f6" weight="fill" />;
}
- Using icons with dynamic properties:
import { CircleNotch } from "@phosphor-icons/react";
function LoadingIndicator({ isLoading }) {
return (
<CircleNotch
size={24}
color={isLoading ? "green" : "gray"}
weight="bold"
mirrored={isLoading}
/>
);
}
Getting Started
- Install the package:
npm install @phosphor-icons/react
- Import and use icons in your React components:
import { House, User, Gear } from "@phosphor-icons/react";
function App() {
return (
<div>
<House size={32} />
<User size={32} color="red" />
<Gear size={32} weight="fill" />
</div>
);
}
Competitor Comparisons
Simply beautiful open-source icons
Pros of Feather
- Larger community and more widespread adoption
- Simpler API with fewer options, making it easier to use for beginners
- Extensive documentation and examples available
Cons of Feather
- Limited customization options compared to Phosphor Icons
- Smaller icon set with fewer choices (around 280 icons vs. 900+ in Phosphor)
- Less frequent updates and new icon additions
Code Comparison
Feather:
import { Icon } from 'react-feather';
<Icon name="user" color="red" size={24} />
Phosphor Icons:
import { User } from 'phosphor-react';
<User size={24} color="red" weight="fill" />
Both libraries offer similar basic usage, but Phosphor Icons provides additional customization options like different icon weights (thin, light, regular, bold, fill, duotone) and mirroring.
Feather focuses on simplicity and ease of use, while Phosphor Icons offers more flexibility and a larger icon set. The choice between the two depends on project requirements, desired customization options, and personal preference.
The iconic SVG, font, and CSS toolkit
Pros of Font-Awesome
- Larger icon set with over 7,000 icons
- Widely adopted and recognized in the web development community
- Supports both SVG and web font formats
Cons of Font-Awesome
- Larger file size, which may impact performance
- Requires more setup and configuration
- Some advanced features are only available in the paid Pro version
Code Comparison
Font-Awesome (React component):
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faUser } from '@fortawesome/free-solid-svg-icons'
<FontAwesomeIcon icon={faUser} />
Phosphor Icons:
import { User } from 'phosphor-react'
<User />
Summary
Font-Awesome offers a vast library of icons and is widely recognized, but it comes with a larger file size and more complex setup. Phosphor Icons provides a simpler implementation and smaller bundle size, but with a more limited icon set. The choice between the two depends on project requirements, performance considerations, and personal preference.
Premium hand-crafted icons built by Ionic, for Ionic apps and web apps everywhere 🌎
Pros of Ionicons
- Larger icon set with over 1,200 icons compared to Phosphor's 886
- Supports multiple frameworks including React, Vue, and Angular
- Includes a custom SVG icon service for easy customization
Cons of Ionicons
- Larger bundle size due to the extensive icon set
- Less frequent updates compared to Phosphor Icons
- More complex setup process for some frameworks
Code Comparison
Phosphor Icons usage:
import { Heart } from "@phosphor-icons/react";
function App() {
return <Heart size={32} color="#FF0000" weight="fill" />;
}
Ionicons usage:
import { IonIcon } from '@ionic/react';
import { heart } from 'ionicons/icons';
function App() {
return <IonIcon icon={heart} style={{fontSize: '32px', color: '#FF0000'}} />;
}
Both libraries offer simple implementation, but Phosphor Icons provides more straightforward prop-based customization, while Ionicons relies on inline styles or CSS for styling.
A scalable set of icons handcrafted with <3 by GitHub
Pros of Octicons
- Officially maintained by GitHub, ensuring consistency with GitHub's design system
- Includes both SVG and PNG formats for broader compatibility
- Offers a wider variety of icon styles, including filled and outlined versions
Cons of Octicons
- Larger package size due to inclusion of multiple formats and styles
- Less frequent updates compared to Phosphor Icons
- More complex implementation, especially for React projects
Code Comparison
Phosphor Icons:
import { Heart } from 'phosphor-react'
function MyComponent() {
return <Heart size={32} color="#ff0000" weight="fill" />
}
Octicons:
import { HeartFillIcon } from '@primer/octicons-react'
function MyComponent() {
return <HeartFillIcon size={32} />
}
Both libraries offer similar ease of use in React projects, with Phosphor Icons providing more customization options directly in the component props. Octicons requires separate imports for different icon styles, while Phosphor Icons allows style changes through the weight
prop.
Overall, Phosphor Icons may be more suitable for React-specific projects due to its lighter weight and simpler implementation, while Octicons is a solid choice for projects closely aligned with GitHub's design system or requiring multiple icon formats.
A set of over 5500 free MIT-licensed high-quality SVG icons for you to use in your web projects.
Pros of Tabler Icons
- Larger icon set with over 3,200 icons compared to Phosphor's 900+
- Supports multiple file formats (SVG, React, Vue, Webfont)
- Offers a wider range of icon styles and categories
Cons of Tabler Icons
- Less focused on React-specific implementation
- May have a steeper learning curve due to the larger set of icons
- Potentially larger bundle size if using the entire icon set
Code Comparison
Tabler Icons (React):
import { IconHome } from '@tabler/icons-react';
function App() {
return <IconHome size={24} color="blue" />;
}
Phosphor Icons:
import { House } from 'phosphor-react';
function App() {
return <House size={24} color="blue" />;
}
Both libraries offer similar usage patterns for React components, with minor differences in naming conventions and import statements. Tabler Icons uses the "Icon" prefix for its components, while Phosphor Icons uses more descriptive names without prefixes.
Material Design icons by Google (Material Symbols)
Pros of Material Design Icons
- Extensive icon set with over 2,000 icons in various styles
- Official Google design system, ensuring consistency with Android and other Google products
- Includes multiple file formats (SVG, PNG, etc.) for versatile usage
Cons of Material Design Icons
- Larger file size due to the comprehensive icon set
- May require additional setup for optimal use in React projects
- Less frequent updates compared to some other icon libraries
Code Comparison
Material Design Icons:
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<i class="material-icons">face</i>
Phosphor Icons:
import { User } from "@phosphor-icons/react";
function MyComponent() {
return <User size={32} color="#61DAFB" weight="fill" />;
}
Key Differences
- Material Design Icons offers a wider variety of icons but requires more setup for React projects
- Phosphor Icons provides a more React-friendly implementation with easier customization
- Material Design Icons follows Google's design language, while Phosphor Icons offers a unique style
- Phosphor Icons has a smaller file size, making it potentially more efficient for web applications
- Material Design Icons supports multiple file formats, whereas Phosphor Icons focuses on React components
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
[!IMPORTANT] As part of a major update, we will be replacing the existing
phosphor-react
package with@phosphor-icons/react
. We recommend using this new version, as it has improved performance and a significantly smaller bundle size. No APIs have been changed, so drop-in replacement should be straightforward. The legacy package will continue to receive maintenance, but will not be updated with new icons upstream. Take me to the legacy version â
@phosphor-icons/react
Phosphor is a flexible icon family for interfaces, diagrams, presentations â whatever, really. Explore all our icons at phosphoricons.com.
Installation
npm i @phosphor-icons/react
Usage
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.
import { Horse, Heart, Cube } from "@phosphor-icons/react";
const App = () => {
return (
<main>
<Horse />
<Heart color="#AE2983" weight="fill" size={32} />
<Cube color="teal" weight="duotone" />
</main>
);
};
React Server Components and SSR
When using Phosphor Icons in an SSR environment, within a React Server Component, or in any environment that does not permit the use of the Context API (Next.js Server Component, for example), import icons from the /dist/ssr
submodule:
import { Fish } from "@phosphor-icons/react/dist/ssr";
const MyServerComponent = () => {
return <Fish weight="duotone" />;
};
[!NOTE] These variants do not use React Context, and thus cannot inherit styles from an ancestor
IconContext
.
Props
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:
- color?:
string
â Icon stroke/fill color. Can be any CSS color string, includinghex
,rgb
,rgba
,hsl
,hsla
, named colors, or the specialcurrentColor
variable. - size?:
number | string
â Icon height & width. As with standard React elements, this can be a number, or a string with units inpx
,%
,em
,rem
,pt
,cm
,mm
,in
. - weight?:
"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 withweight="regular"
to denote an empty star, andweight="fill"
to denote a filled star. - mirrored?:
boolean
â Flip the icon horizontally. Can be useful in RTL languages where normal icon orientation is not appropriate. - alt?:
string
â Add accessible alt text to an icon.
Context
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:
import { IconContext, Horse, Heart, Cube } from "@phosphor-icons/react";
const App = () => {
return (
<IconContext.Provider
value={{
color: "limegreen",
size: 32,
weight: "bold",
mirrored: false,
}}
>
<div>
<Horse /> {/* I'm lime-green, 32px, and bold! */}
<Heart /> {/* Me too! */}
<Cube /> {/* Me three :) */}
</div>
</IconContext.Provider>
);
};
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.
[!NOTE] The context will also pass any provided SVG props down to icon instances, which can be useful E.G. in adding accessible
aria-label
s,classNames
, etc.
[!NOTE] React Context is not available in some environments. See React Server Components and SSR for details.
Composability
Components can accept arbitrary SVG elements as children, so long as they are valid children of the <svg>
element. This can be used to modify an icon with background layers or shapes, filters, animations, and more. The children will be placed below the normal icon contents.
The following will cause the Cube icon to rotate and pulse:
const RotatingCube = () => {
return (
<Cube color="darkorchid" weight="duotone">
<animate
attributeName="opacity"
values="0;1;0"
dur="4s"
repeatCount="indefinite"
></animate>
<animateTransform
attributeName="transform"
attributeType="XML"
type="rotate"
dur="5s"
from="0 0 0"
to="360 0 0"
repeatCount="indefinite"
></animateTransform>
</Cube>
);
};
[!NOTE] The coordinate space of slotted elements is relative to the contents of the icon
viewBox
, which is 256x256 square. Only valid SVG elements will be rendered.
Imports
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.
import * as Icon from "@phosphor-icons/react";
<Icon.Smiley />
<Icon.Folder weight="thin" />
<Icon.BatteryHalf size="24px" />
For information on using Phosphor Icons in Server Components, see See React Server Components and SSR.
Custom Icons
It is possible to extend Phosphor with your custom icons, taking advantage of the styling and context abstractions used in our library. To create a custom icon, first design your icons on a 256x256 pixel grid, and export them as SVG. For best results, flatten the icon so that you only export assets with path
elements. Strip any fill
or stroke
attributes, as these will be inherited from the wrapper.
Next, create a new React forwardRef
component, importing the IconBase
component, as well as the Icon
and IconWeight
types from this library. Define a Map<IconWeight, ReactElement>
that maps each icon weight to the contents of each SVG asset, effectively removing the wrapping <svg>
element from each. Name your component, and render an <IconBase />
, passing all props and the ref, as well as the weights
you defined earlier, as JSX props:
import { forwardRef, ReactElement } from "react";
import { Icon, IconBase, IconWeight } from "@phosphor-icons/react";
const weights = new Map<IconWeight, ReactElement>([
["thin", <path d="..." />],
["light", <path d="..." />],
["regular", <path d="..." />],
["bold", <path d="..." />],
["fill", <path d="..." />],
[
"duotone",
<>
<path d="..." opacity="0.2" />
<path d="..." />
</>,
],
]);
const CustomIcon: Icon = forwardRef((props, ref) => (
<IconBase ref={ref} {...props} weights={weights} />
));
CustomIcon.displayName = "CustomIcon";
export default CustomIcon;
[!NOTE] If you have multiple child elements, wrap them in a
Fragment
. Typically ourduotone
icons have multiple elements, with the background layer at 20% opacity.
If Custom Icons are intended to be used in React Server Components, use <SSRBase />
instead of <IconBase />
as the render component.
Our Related Projects
- @phosphor-icons/homepage â² Phosphor homepage and general info
- @phosphor-icons/core â² Phosphor icon assets and catalog
- @phosphor-icons/react â² Phosphor icon component library for React
- @phosphor-icons/web â² Phosphor icons for Vanilla JS
- @phosphor-icons/vue â² Phosphor icon component library for Vue
- @phosphor-icons/swift â² Phosphor icon component library for SwiftUI
- @phosphor-icons/elm â² Phosphor icons for Elm
- @phosphor-icons/flutter â² Phosphor IconData library for Flutter
- @phosphor-icons/webcomponents â² Phosphor icons as Web Components
- @phosphor-icons/figma â² Phosphor icons Figma plugin
- @phosphor-icons/sketch â² Phosphor icons Sketch plugin
- @phosphor-icons/pack â² Phosphor web font stripper to generate minimal icon bundles
- @phosphor-icons/theme â² A VS Code (and other IDE) theme with the Phosphor color palette
Community Projects
- phosphor-react-native â² Phosphor icon component library for React Native
- phosphor-svelte â² Phosphor icons for Svelte apps
- phosphor-r â² Phosphor icon wrapper for R documents and applications
- blade-phosphor-icons â² Phosphor icons in your Laravel Blade views
- wireui/phosphoricons â² Phosphor icons for Laravel
- phosphor-css â² CSS wrapper for Phosphor SVG icons
- ruby-phosphor-icons â² Phosphor icons for Ruby and Rails applications
- eleventy-plugin-phosphoricons â² An Eleventy plugin for add shortcode, allows Phosphor icons to be embedded as inline svg into templates
- phosphor-leptos â² Phosphor icon component library for Leptos apps (rust)
- wordpress-phosphor-icons-block â² Phosphor icon block for use in WordPress v5.8+
- ember-phosphor-icons â² Phosphor icons for Ember apps
If you've made a port of Phosphor and you want to see it here, just open a PR here!
License
MIT © Phosphor Icons
Top Related Projects
Simply beautiful open-source icons
The iconic SVG, font, and CSS toolkit
Premium hand-crafted icons built by Ionic, for Ionic apps and web apps everywhere 🌎
A scalable set of icons handcrafted with <3 by GitHub
A set of over 5500 free MIT-licensed high-quality SVG icons for you to use in your web projects.
Material Design icons by Google (Material Symbols)
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot