svg react icons of popular icon packs
Installations
npm install react-icons
Developer
Developer Guide
Module System
CommonJS, ESM
Min. Node Version
Typescript Support
Yes
Node Version
18.14.2
NPM Version
9.5.0
Statistics
11,688 Stars
678 Commits
754 Forks
53 Watching
13 Branches
108 Contributors
Updated on 27 Nov 2024
Bundle Size
7.61 kB
Minified
2.21 kB
Minified + Gzipped
Languages
TypeScript (61.7%)
JavaScript (13.5%)
SCSS (10.15%)
Astro (9.56%)
HTML (3.13%)
CSS (1.39%)
Shell (0.57%)
Total Downloads
Cumulative downloads
Total Downloads
343,361,789
Last day
-1.4%
482,610
Compared to previous day
Last week
3.8%
2,621,354
Compared to previous week
Last month
10.3%
10,836,386
Compared to previous month
Last year
31.6%
109,128,062
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Peer Dependencies
1
React Icons
Include popular icons in your React projects easily with react-icons
, which utilizes ES6 imports that allows you to include only the icons that your project is using.
Installation (for standard modern project)
1yarn add react-icons 2# or 3npm install react-icons --save
example usage
1import { FaBeer } from "react-icons/fa"; 2 3function Question() { 4 return ( 5 <h3> 6 Lets go for a <FaBeer />? 7 </h3> 8 ); 9}
View the documentation for further usage examples and how to use icons from other packages. NOTE: each Icon package has it's own subfolder under react-icons
you import from.
For example, to use an icon from Material Design, your import would be: import { ICON_NAME } from 'react-icons/md';
Installation (for meteorjs, gatsbyjs, etc)
Note This option has not had a new release for some time. More info https://github.com/react-icons/react-icons/issues/593
If your project grows in size, this option is available. This method has the trade-off that it takes a long time to install the package.
1yarn add @react-icons/all-files 2# or 3npm install @react-icons/all-files --save
example usage
1import { FaBeer } from "@react-icons/all-files/fa/FaBeer"; 2 3function Question() { 4 return ( 5 <h3> 6 Lets go for a <FaBeer />? 7 </h3> 8 ); 9}
Icons
You can add more icons by submitting pull requests or creating issues.
Configuration
You can configure react-icons props using React Context API.
Requires React 16.3 or higher.
1import { IconContext } from "react-icons"; 2 3<IconContext.Provider value={{ color: "blue", className: "global-class-name" }}> 4 <div> 5 <FaFolder /> 6 </div> 7</IconContext.Provider>;
Key | Default | Notes |
---|---|---|
color | undefined (inherit) | |
size | 1em | |
className | undefined | |
style | undefined | Can overwrite size and color |
attr | undefined | Overwritten by other attributes |
title | undefined | Icon description for accessibility |
Migrating from version 2 -> 3
Change import style
Import path has changed. You need to rewrite from the old style.
1// OLD IMPORT STYLE 2import FaBeer from "react-icons/lib/fa/beer"; 3 4function Question() { 5 return ( 6 <h3> 7 Lets go for a <FaBeer />? 8 </h3> 9 ); 10}
1// NEW IMPORT STYLE 2import { FaBeer } from "react-icons/fa"; 3 4function Question() { 5 return ( 6 <h3> 7 Lets go for a <FaBeer />? 8 </h3> 9 ); 10}
Ending up with a large JS bundle? Check out this issue.
Adjustment CSS
From version 3, vertical-align: middle
is not automatically given. Please use IconContext to specify className or specify an inline style.
Global Inline Styling
1<IconContext.Provider value={{ style: { verticalAlign: 'middle' } }}>
Global className
Styling
Component
1<IconContext.Provider value={{ className: 'react-icons' }}>
CSS
1.react-icons { 2 vertical-align: middle; 3}
TypeScript native support
Dependencies on @types/react-icons
can be deleted.
Yarn
1yarn remove @types/react-icons
NPM
1npm remove @types/react-icons
Contributing
./build-script.sh
will build the whole project. See also CI scripts for more information.
Development
1yarn 2cd packages/react-icons 3yarn fetch # fetch icon sources 4yarn build
Add/Update icon set
First, check the discussion to see if anyone would like to add an icon set.
https://github.com/react-icons/react-icons/discussions/categories/new-icon-set
The SVG files to be fetched are managed in this file. Edit this file and run yarn fetch && yarn check && yarn build
.
https://github.com/react-icons/react-icons/blob/master/packages/react-icons/src/icons/index.ts
Preview
Note The project is not actively accepting PR for the preview site at this time.
The preview site is the react-icons
website, built in Astro+React.
1cd packages/react-icons 2yarn fetch 3yarn build 4 5cd ../preview-astro 6yarn start
Demo
The demo is a Create React App boilerplate with react-icons
added as a dependency for easy testing.
1cd packages/react-icons 2yarn fetch 3yarn build 4 5cd ../demo 6yarn start
Why React SVG components instead of fonts?
SVG is supported by all major browsers. With react-icons
, you can serve only the needed icons instead of one big font file to the users, helping you to recognize which icons are used in your project.
Related Projects
Licence
MIT
- Icons are taken from the other projects so please check each project licences accordingly.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Warn: project license file does not contain an FSF or OSI license.
Reason
3 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 2
Reason
Found 3/24 approved changesets -- score normalized to 1
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/nodejs.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/react-icons/react-icons/nodejs.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/react-icons/react-icons/nodejs.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:29: update your workflow using https://app.stepsecurity.io/secureworkflow/react-icons/react-icons/nodejs.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/nodejs.yml:33: update your workflow using https://app.stepsecurity.io/secureworkflow/react-icons/react-icons/nodejs.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/nodejs.yml:52: update your workflow using https://app.stepsecurity.io/secureworkflow/react-icons/react-icons/nodejs.yml/master?enable=pin
- Info: 0 out of 3 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 2 third-party GitHubAction dependencies pinned
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
Project has not signed or included provenance with any releases.
Details
- Warn: release artifact v5.3.0 not signed: https://api.github.com/repos/react-icons/react-icons/releases/169892833
- Warn: release artifact v5.2.1 not signed: https://api.github.com/repos/react-icons/react-icons/releases/153783604
- Warn: release artifact v5.2.0 not signed: https://api.github.com/repos/react-icons/react-icons/releases/153615048
- Warn: release artifact v5.1.0 not signed: https://api.github.com/repos/react-icons/react-icons/releases/151097518
- Warn: release artifact v5.0.1 not signed: https://api.github.com/repos/react-icons/react-icons/releases/136604791
- Warn: release artifact v5.3.0 does not have provenance: https://api.github.com/repos/react-icons/react-icons/releases/169892833
- Warn: release artifact v5.2.1 does not have provenance: https://api.github.com/repos/react-icons/react-icons/releases/153783604
- Warn: release artifact v5.2.0 does not have provenance: https://api.github.com/repos/react-icons/react-icons/releases/153615048
- Warn: release artifact v5.1.0 does not have provenance: https://api.github.com/repos/react-icons/react-icons/releases/151097518
- Warn: release artifact v5.0.1 does not have provenance: https://api.github.com/repos/react-icons/react-icons/releases/136604791
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 16 are checked with a SAST tool
Reason
19 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-m85w-3h95-hcf9
- Warn: Project is vulnerable to: GHSA-qwcr-r2fm-qrc7
- Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-f6v4-cf5j-vf3w
- Warn: Project is vulnerable to: GHSA-qw6h-vgh9-j6wx
- Warn: Project is vulnerable to: GHSA-c7qv-q95q-8v27
- Warn: Project is vulnerable to: GHSA-78xj-cgh5-2h22
- Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp
- Warn: Project is vulnerable to: GHSA-rp65-9cf3-cjxr
- Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j
- Warn: Project is vulnerable to: GHSA-7fh5-64p2-3v2j
- Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm
- Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg
- Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
- Warn: Project is vulnerable to: GHSA-64vr-g452-qvp3
- Warn: Project is vulnerable to: GHSA-9cwx-2883-4wfx
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
Score
2.8
/10
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More