styled-icons
💅 Popular icon packs like Font Awesome, Material Design, and Octicons, available as React Styled Components
Top Related Projects
Universal icon framework. One syntax for FontAwesome, Material Design Icons, DashIcons, Feather Icons, EmojiOne, Noto Emoji and many other open source icon sets (over 150 icon sets and 200k icons). SVG framework, React, Vue and Svelte components!
The iconic SVG, font, and CSS toolkit
Simply beautiful open-source icons
A scalable set of icons handcrafted with <3 by GitHub
A set of over 5800 free MIT-licensed high-quality SVG icons for you to use in your web projects.
Premium hand-crafted icons built by Ionic, for Ionic apps and web apps everywhere 🌎
Quick Overview
Styled Icons is a comprehensive collection of popular icon packs as React components, compatible with styled-components. It provides easy access to thousands of icons from various icon libraries, allowing developers to use them as styled React components in their projects.
Pros
- Large selection of icons from multiple popular icon packs
- Easy integration with React and styled-components
- Consistent API across different icon sets
- Regular updates with new icons and icon packs
Cons
- Large package size if importing all icons
- Potential performance impact if not using tree-shaking
- Limited customization options compared to using SVGs directly
- Dependency on styled-components may not fit all project architectures
Code Examples
- Importing and using an icon:
import { Github } from '@styled-icons/boxicons-logos/Github'
const MyComponent = () => (
<div>
<Github size={48} />
</div>
)
- Styling an icon using styled-components:
import { styled } from 'styled-components'
import { Heart } from '@styled-icons/boxicons-solid/Heart'
const RedHeart = styled(Heart)`
color: red;
`
const MyComponent = () => (
<div>
<RedHeart size={32} />
</div>
)
- Using an icon with custom props:
import { ArrowRight } from '@styled-icons/heroicons-solid/ArrowRight'
const MyComponent = () => (
<button>
Next <ArrowRight size={16} aria-hidden="true" />
</button>
)
Getting Started
- Install the package and its peer dependencies:
npm install @styled-icons/boxicons-logos styled-components
- Import and use an icon in your React component:
import React from 'react'
import { Github } from '@styled-icons/boxicons-logos/Github'
const MyComponent = () => (
<div>
<h1>Welcome to my project</h1>
<Github size={48} title="GitHub" />
</div>
)
export default MyComponent
Note: Make sure to import only the specific icons you need to keep your bundle size small. The @styled-icons
package provides separate imports for each icon pack to facilitate tree-shaking.
Competitor Comparisons
Universal icon framework. One syntax for FontAwesome, Material Design Icons, DashIcons, Feather Icons, EmojiOne, Noto Emoji and many other open source icon sets (over 150 icon sets and 200k icons). SVG framework, React, Vue and Svelte components!
Pros of Iconify
- Larger icon set with over 100,000 icons from various collections
- Supports multiple frameworks and can be used with vanilla JavaScript
- Offers on-demand loading, reducing initial bundle size
Cons of Iconify
- More complex setup and configuration
- Requires additional API calls for on-demand loading, which may impact performance
Code Comparison
Styled Icons:
import { Github } from '@styled-icons/boxicons-logos/Github'
const MyComponent = () => (
<Github size={24} />
)
Iconify:
import { Icon } from '@iconify/react'
const MyComponent = () => (
<Icon icon="bx:bxl-github" width={24} height={24} />
)
Summary
Iconify offers a vast icon library with flexible framework support and on-demand loading, but comes with a more complex setup. Styled Icons provides a simpler, more straightforward implementation but with a more limited icon set. The choice between the two depends on project requirements, desired icon variety, and performance considerations.
The iconic SVG, font, and CSS toolkit
Pros of Font-Awesome
- Larger icon set with over 7,000 icons
- Widely recognized and used, with extensive community support
- Offers both free and paid versions with additional features
Cons of Font-Awesome
- Requires additional CSS and JavaScript files for full functionality
- Can be heavier in terms of file size, especially when using the entire library
Code Comparison
Font-Awesome (HTML):
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
<i class="fas fa-user"></i>
styled-icons (React):
import { User } from '@styled-icons/fa-solid/User'
<User size="24" />
Key Differences
- Integration: Font-Awesome uses CSS classes, while styled-icons leverages React components.
- Customization: styled-icons offers easier customization through props and styled-components.
- Bundle size: styled-icons allows for more granular imports, potentially reducing bundle size.
- Ecosystem: Font-Awesome has a larger ecosystem with various tools and integrations.
- Typescript support: styled-icons provides better TypeScript support out of the box.
Both libraries offer high-quality icon sets, but they cater to different use cases and development preferences. Font-Awesome is more versatile across various web technologies, while styled-icons is optimized for React-based projects with a focus on modern development practices.
Simply beautiful open-source icons
Pros of Feather
- Lightweight and minimalist design, focusing on simplicity and consistency
- Offers SVG icons, which are scalable and customizable
- Provides a command-line interface for easy icon management
Cons of Feather
- Limited icon set compared to Styled Icons
- Lacks built-in support for popular frontend frameworks like React or Vue
Code Comparison
Feather:
import { feather } from 'feather-icons'
feather.icons.x.toSvg()
Styled Icons:
import { X } from '@styled-icons/feather/X'
<X size={24} />
Key Differences
- Styled Icons wraps multiple icon libraries, including Feather, providing a unified API
- Styled Icons offers React components out of the box, while Feather requires additional setup for framework integration
- Styled Icons provides TypeScript support and tree-shaking, which Feather lacks
Use Cases
- Choose Feather for lightweight, framework-agnostic projects requiring simple SVG icons
- Opt for Styled Icons in React-based applications or when needing a diverse icon set from multiple sources
Community and Maintenance
- Feather has a larger GitHub community with more stars and contributors
- Styled Icons offers more frequent updates and actively maintains support for various icon libraries
A scalable set of icons handcrafted with <3 by GitHub
Pros of Octicons
- Official GitHub icon set, ensuring consistency with GitHub's design language
- Includes SVG and PNG formats, offering flexibility for different use cases
- Provides a web font option for easy implementation in web projects
Cons of Octicons
- Limited to GitHub-specific icons, which may not cover all use cases
- Fewer total icons compared to Styled Icons' extensive collection
- Less frequent updates and additions to the icon set
Code Comparison
Octicons usage:
<span class="octicon octicon-mark-github"></span>
Styled Icons usage:
import { GithubIcon } from '@styled-icons/boxicons-logos/Github'
const MyComponent = () => <GithubIcon size={24} />
Key Differences
- Styled Icons offers a wider variety of icon sets from multiple sources
- Octicons focuses solely on GitHub's design system
- Styled Icons provides easier integration with React and styled-components
- Octicons offers more traditional implementation methods (CSS classes, web fonts)
Both libraries serve different purposes: Octicons is ideal for projects closely aligned with GitHub's design, while Styled Icons offers more versatility for general web development needs.
A set of over 5800 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,000 icons
- SVG-based icons, providing better scalability and customization
- Includes both stroke and fill versions for many icons
Cons of Tabler Icons
- Less integration with popular styling libraries like styled-components
- Requires more manual setup for React projects
- Limited built-in TypeScript support
Code Comparison
Styled Icons usage:
import { Github } from '@styled-icons/boxicons-logos/Github'
const MyComponent = () => (
<Github size={24} color="blue" />
)
Tabler Icons usage:
import { IconGithub } from '@tabler/icons-react'
const MyComponent = () => (
<IconGithub size={24} color="blue" stroke={2} />
)
Both libraries offer easy-to-use React components for icons, but Styled Icons provides more seamless integration with styled-components and other CSS-in-JS solutions. Tabler Icons, on the other hand, offers more customization options like stroke width and a larger variety of icons.
While Styled Icons focuses on providing a wide range of icon sets from various sources, Tabler Icons offers a cohesive and consistent icon design across its entire library. This makes Tabler Icons potentially more suitable for projects requiring a unified visual language.
Premium hand-crafted icons built by Ionic, for Ionic apps and web apps everywhere 🌎
Pros of Ionicons
- Larger icon set with over 1,300 icons
- Supports multiple file formats (SVG, WebFont, PNG)
- Includes a custom icon creation tool
Cons of Ionicons
- Less flexible styling options compared to styled-icons
- Requires additional setup for React projects
- Larger bundle size due to comprehensive icon set
Code Comparison
Ionicons usage in React:
import { IonIcon } from '@ionic/react';
import { heart } from 'ionicons/icons';
function MyComponent() {
return <IonIcon icon={heart} />;
}
styled-icons usage in React:
import { Heart } from '@styled-icons/ionicons-solid/Heart';
function MyComponent() {
return <Heart size={24} />;
}
Summary
Ionicons offers a more extensive icon set with multiple file format support, making it versatile for various project types. However, styled-icons provides better integration with React and styled-components, offering more flexibility in styling and easier implementation for React developers. The choice between the two depends on the specific project requirements, with Ionicons being more suitable for general-purpose use and styled-icons excelling in React-based projects with custom styling needs.
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
ð styled-icons
styled-icons
provides over 20,000 icons from the following icon packs as Styled Components, with full support for TypeScript types and tree-shaking / ES modules.
- Bootstrap
- Boxicons
- Crypto Icons
- Entypo
- Eva Icons
- Evil Icons
- Feather
- FluentUI System
- Font Awesome
- Foundation
- Heroicons
- Icomoon
- Ionicons
- Material Design
- Octicons
- Open Iconic
- Remix
- Simple Icons
- Typicons
- Zondicons
Do you use Emotion?
Check out ð©âð¤ Emotion Icons
Would you prefer plain SVGs?
Check out ðï¸ SVG Icons
Table of Contents
Installation
You can install all the icon packs simultaneously:
yarn add styled-icons
or
npm install styled-icons --save
Alternatively you can install only the icon packs you need:
yarn add @styled-icons/bootstrap
yarn add @styled-icons/boxicons-logos
yarn add @styled-icons/boxicons-regular
yarn add @styled-icons/boxicons-solid
yarn add @styled-icons/crypto
yarn add @styled-icons/entypo
yarn add @styled-icons/entypo-social
yarn add @styled-icons/evaicons-outline
yarn add @styled-icons/evaicons-solid
yarn add @styled-icons/evil
yarn add @styled-icons/fa-brands
yarn add @styled-icons/fa-regular
yarn add @styled-icons/fa-solid
yarn add @styled-icons/feather
yarn add @styled-icons/fluentui-system-filled
yarn add @styled-icons/fluentui-system-regular
yarn add @styled-icons/foundation
yarn add @styled-icons/heroicons-outline
yarn add @styled-icons/heroicons-solid
yarn add @styled-icons/icomoon
yarn add @styled-icons/ionicons-sharp
yarn add @styled-icons/ionicons-solid
yarn add @styled-icons/ionicons-outline
yarn add @styled-icons/material
yarn add @styled-icons/material-outlined
yarn add @styled-icons/material-rounded
yarn add @styled-icons/material-twotone
yarn add @styled-icons/material-sharp
yarn add @styled-icons/octicons
yarn add @styled-icons/open-iconic
yarn add @styled-icons/remix-fill
yarn add @styled-icons/remix-editor
yarn add @styled-icons/remix-line
yarn add @styled-icons/simple-icons
yarn add @styled-icons/typicons
yarn add @styled-icons/zondicons
Finally, you will need to have installed a version of styled-components
at least version 4.1.0 or newer, as styled-icons
depends on styled-components
as a peer dependency.
Usage
All icons are available for preview at the Icon Explorer.
The entire icon packs are available via the main import and sub-imports:
import {material, octicons} from 'styled-icons'
import * as bootstrap from '@styled-icons/bootstrap'
import * as boxiconsLogos from '@styled-icons/boxicons-logos'
import * as boxiconsRegular from '@styled-icons/boxicons-regular'
import * as boxiconsSolid from '@styled-icons/boxicons-solid'
import * as crypto from '@styled-icons/crypto'
import * as entypo from '@styled-icons/entypo'
import * as entypoSocial from '@styled-icons/entypo-social'
import * as evaiconsOutline from '@styled-icons/evaicons-outline'
import * as evaiconsSolid from '@styled-icons/evaicons-solid'
import * as evil from '@styled-icons/evil'
import * as faBrands from '@styled-icons/fa-brands'
import * as faRegular from '@styled-icons/fa-regular'
import * as faSolid from '@styled-icons/fa-solid'
import * as feather from '@styled-icons/feather'
import * as fluentUISystemFilled from '@styled-icons/fluentui-system-filled'
import * as fluentUISystemRegular from '@styled-icons/fluentui-system-regular'
import * as foundation from '@styled-icons/foundation'
import * as heroiconsOutline from '@styled-icons/heroicons-outline'
import * as heroiconsSolid from '@styled-icons/heroicons-solid'
import * as icomoon from '@styled-icons/icomoon'
import * as ioniconsSharp from '@styled-icons/ionicons-sharp'
import * as ioniconsSolid from '@styled-icons/ionicons-solid'
import * as ioniconsOutline from '@styled-icons/ionicons-outline'
import * as material from '@styled-icons/material'
import * as materialOutlined from '@styled-icons/material-outlined'
import * as materialRounded from '@styled-icons/material-rounded'
import * as materialSharp from '@styled-icons/material-sharp'
import * as materialTwoTone from '@styled-icons/material-twotone'
import * as octicons from '@styled-icons/octicons'
import * as openIconic from '@styled-icons/open-iconic'
import * as remixFill from '@styled-icons/remix-fill'
import * as remixEditor from '@styled-icons/remix-editor'
import * as remixLine from '@styled-icons/remix-line'
import * as simpleIcons from '@styled-icons/simple-icons'
import * as typicons from '@styled-icons/typicons'
import * as zondicons from '@styled-icons/zondicons'
You can also import just the icons you need:
import React, {Fragment} from 'react'
import {AccountCircle, Lock} from '@styled-icons/material'
const App = () => (
<Fragment>
<AccountCircle />
<Lock />
</Fragment>
)
For the individual icon pack packages (@styled-icons/PACK
), the icons are also importable individually - this is not possible with the uber-styled-icons
package containing all the packs:
import React from 'react'
import {Lock} from '@styled-icons/material/Lock'
const App = () => <Lock />
Props
Styled Icons accept all the valid props of an <svg />
element, in addition to the following custom props:
Prop | Required | Type | Description |
---|---|---|---|
size | optional | string, number | This is a convenience for setting both width and height to the same value |
title | optional | string | This sets the icon title and enables the standalone icon accessibility mode. See accessibility below for additional details |
Example
import React from 'react'
import {Lock} from '@styled-icons/material'
const App = () => <Lock size="48" title="Unlock account" />
Icon Dimensions
Some icons natively have non-square dimensions - original dimensions are exported from the individual icon exports:
import {LogoGithub, LogoGithubDimensions} from '@styled-icons/octicons/LogoGithub'
const App = () => <LogoGithub />
console.log(LogoGithubDimension) // {height: 16, width: 45}
Dimension exports are not available on the icon pack or index exports:
import * as octicons from '@styled-icons/octicons'
import {octicons} from 'styled-icons'
// octicons contains only icon exports
Styled Components
All icons are exported as Styled Components, which means it is possible to utilize the Styled Components API:
import styled from 'styled-components'
import {Lock} from '@styled-icons/material'
export const RedLock = styled(Lock)`
color: red;
font-weight: ${(props) => (props.important ? 'bold' : 'normal')};
`
Base Icon Styles
If you wish to style all icons at once, you can create a wrapper styled component that imparts a particular style to all icons contained within the wrapper by targeting the StyledIconBase
component:
import styled from 'styled-components'
import {StyledIconBase} from '@styled-icons/styled-icon'
export const IconStyleWrapper = styled.div`
${StyledIconBase} {
color: red;
/* icon styles go here */
}
`
Accessibility
Styled Icons have two different built-in "modes" for accessibility purposes. By default, icons are considered decorative, meaning the icon is just visual sugar and the surrounding content is sufficient for conveying meaning. This will set the aria-hidden
attribute on the resulting HTML to hide the icon from screen readers.
// this icon
<Lock />
// will result in
<svg aria-hidden="true">...</svg>
Alternatively the icon could be used in standalone mode, meaning the icon itself should convey meaning. This mode is enabled by setting a title
prop - this is the text that will be read by a screen reader. This results in role
being set to img
and the addition of a <title>
element.
// this icon
<Lock title="Lock account" />
// will result in
<svg role="img"><title>Lock account</title> ...</svg>
Since Style Icons accept all <svg>
element attributes as props, you are free to override these aria-*
attributes if you have a more complex use-case.
As this library provides direct access to the <svg>
element, you may wish to further wrap the icon for additional semantic meaning. For example, for a loading spinner:
import styled from 'styled-components'
import {Spinner} from '@styled-icons/fa-solid/Spinner'
const VisuallyHidden = styled.span`
border: 0 !important;
clip: rect(1px, 1px, 1px, 1px) !important;
height: 1px !important;
overflow: hidden !important;
padding-top: 0 !important;
padding-right: 0 !important;
padding-bottom: 0 !important;
padding-left: 0 !important;
position: absolute !important;
white-space: nowrap !important;
width: 1px !important;
`
<span title="Loading posts..." role="alert" aria-live="assertive">
<Spinner />
<VisuallyHidden>Loading posts...</VisuallyHidden>
</span>
Tree Shaking
Styled Icons supports automatic tree-shaking via the package.json
module
property from any of the import paths (icon pack, individual icon, etc.). Tree shaking has been tested with Create React App v2, Next.js, Rollup, and Webpack v4.
TypeScript
The icons of styled-icons
are built using TypeScript and export type definitions. If you need a type to reference any styled icon, there is a StyledIcon
type exported from the @styled-icons/styled-icon
package (recommended) or the styled-icons/types
import:
import styled from 'styled-components'
// Recommended:
import {StyledIcon} from '@styled-icons/styled-icon'
// Alternatively:
import {StyledIcon} from 'styled-icons/types'
interface Props {
icon: StyledIcon
}
NOTE: you should ensure that the version of @types/react
in your project is at least 16.8.14
or greater. That version of the React types package added support for ARIA attributes on SVG elements, which Styled Icons uses.
If you have any ideas for improvements to the TypeScript typing, please open an issue or PR!
Contributing
Contributions are welcome! Feel free to open an issue or a pull request and participate at whatever level you would like.
License
The MIT License - see LICENSE
.
The Bootstrap icons are licensed under the MIT License.
The Boxicons are licensed under the CC BY 4.0 License.
The Cryptocurrency icons are licensed under the CC0 1.0 Universal License.
The Entypo icons are licensed under the CC BY-SA 4.0 License.
The Eva Icons are licensed under the MIT License.
The Evil Icons are licensed under the MIT License.
The Font Awesome icons are licensed under the CC BY 4.0 License.
The Feather icons are licensed under the MIT License.
The FluentUI System icons are licensed under the MIT License.
The Foundation icons are licensed under the MIT License.
The Heroicons are licensed under the MIT License.
The Icomoon icons are dual licensed under GPL / CC BY 4.0 License.
The Ionicons are licensed under the MIT License.
The Material Design icons are licensed under the Apache License Version 2.0.
The Octicons are licensed under the MIT License.
The Open Iconic icons are licensed under the MIT License.
The Remix icons are licensed under the Apache License 2.0.
The Simple Icons are licensed under the CC0 1.0 Universal License.
The Typicons are licensed under the CC BY SA 3.0 License.
The Zondicons are licensed under the MIT License.
Contributors
Thank you to all our backers! ð [Become a backer]
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]
Top Related Projects
Universal icon framework. One syntax for FontAwesome, Material Design Icons, DashIcons, Feather Icons, EmojiOne, Noto Emoji and many other open source icon sets (over 150 icon sets and 200k icons). SVG framework, React, Vue and Svelte components!
The iconic SVG, font, and CSS toolkit
Simply beautiful open-source icons
A scalable set of icons handcrafted with <3 by GitHub
A set of over 5800 free MIT-licensed high-quality SVG icons for you to use in your web projects.
Premium hand-crafted icons built by Ionic, for Ionic apps and web apps everywhere 🌎
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