react-icons
SVG React icons of popular icon packs using ES6 imports
Last updated 8 years ago by kamijin_fanta .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install react-icons 
SYNC missed versions from official npm registry.
React Icons

React Icons

npm

Include popular icons in your React projects easly with react-icons, which utilizes ES6 imports that allows you to include only the icons that your project is using.

Installation

npm install react-icons --save

Usage

import { FaBeer } from 'react-icons/fa';

class Question extends React.Component {
    render() {
        return <h3> Lets go for a <FaBeer />? </h3>
    }
}

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';

Icons

You can add more icons by submitting pull requests or creating issues.

Configuration

You can configure react-icons props using React context API.

requirement React 16.3 or higher.

import { IconContext } from "react-icons";

<IconContext.Provider value={{ color: "blue", className: "global-class-name" }}>
  <div>
    <FaFolder />
  </div>
</IconContext.Provider>
key default memo
color undefined(inherit)
size 1em
className undefined
style undefined can overwrite size and color
attr undefined overwritten by other attributes

Migrate from version 2 -> 3

Change import style

Import path has changed. You need to rewrite from the old style.

// OLD IMPORT STYLE
import FaBeer from 'react-icons/lib/fa/beer';

class Question extends React.Component {
    render() {
        return <h3> Lets go for a <FaBeer />? </h3>
    }
}
// NEW IMPORT STYLE
import { FaBeer } from 'react-icons/fa';

class Question extends React.Component {
    render() {
        return <h3> Lets go for a <FaBeer />? </h3>
    }
}

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 style.

example for global styling

<IconContext.Provider value={{ style: { verticalAlign: 'middle' } }}>

example for give global className

// app.tsx
<IconContext.Provider value={{ className: 'react-icons' }}>

// app.css
.react-icons {
  vertical-align: middle;
}

TypeScript native support

Dependencies on @types/react-icons can be deleted.

npm remove @types/react-icons

Contribute

development

yarn
yarn submodule  # fetch icon sources
cd packages/react-icons
yarn build

scripts for run demo

cd packages/react-icons
yarn build
cd ../demo
yarn start

run preview site

cd packages/react-icons
yarn build
cd ../preview
yarn start

Tips

SVG

Svg is supported by all major browsers.

Why ES6 import and not fonts

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

Licence

MIT

  • Icons are taken from the other projects so please check each project licences accordingly.

Current Tags

  • 6.0.0-beta.0                                ...           beta (4 months ago)
  • 5.7.0                                ...           latest (5 months ago)

87 Versions

  • 6.0.0-beta.0                                ...           4 months ago
  • 5.7.0                                ...           5 months ago
  • 5.6.0                                ...           9 months ago
  • 5.5.0                                ...           2 years ago
  • 5.4.0                                ...           2 years ago
  • 5.3.0                                ...           2 years ago
  • 5.2.1                                ...           3 years ago
  • 5.2.0                                ...           3 years ago
  • 5.1.0                                ...           3 years ago
  • 5.0.1                                ...           3 years ago
  • 5.0.0                                ...           3 years ago
  • 4.12.0                                ...           3 years ago
  • 4.11.0                                ...           3 years ago
  • 4.10.1                                ...           3 years ago
  • 4.10.0                                ...           3 years ago
  • 4.9.0                                ...           4 years ago
  • 4.8.1-snapshot.2                                ...           4 years ago
  • 4.8.1-snapshot.1                                ...           4 years ago
  • 4.8.1-snapshot.0                                ...           4 years ago
  • 4.8.0                                ...           4 years ago
  • 4.7.1                                ...           4 years ago
  • 4.6.0                                ...           4 years ago
  • 4.4.0                                ...           4 years ago
  • 4.3.1                                ...           5 years ago
  • 4.3.0                                ...           5 years ago
  • 4.2.0                                ...           6 years ago
  • 4.1.0                                ...           6 years ago
  • 4.0.0                                ...           6 years ago
  • 3.11.0                                ...           6 years ago
  • 3.10.0                                ...           7 years ago
  • 3.9.0                                ...           7 years ago
  • 3.8.0                                ...           7 years ago
  • 3.7.0                                ...           8 years ago
  • 3.6.1                                ...           8 years ago
  • 3.6.0                                ...           8 years ago
  • 3.6.0-beta2                                ...           8 years ago
  • 3.6.0-beta1                                ...           8 years ago
  • 3.5.0                                ...           8 years ago
  • 3.4.0                                ...           8 years ago
  • 3.3.0                                ...           8 years ago
  • 3.2.2                                ...           8 years ago
  • 3.2.1                                ...           8 years ago
  • 3.2.0                                ...           8 years ago
  • 3.1.0                                ...           8 years ago
  • 3.1.0-beta.1                                ...           8 years ago
  • 3.0.5                                ...           8 years ago
  • 3.0.4                                ...           8 years ago
  • 3.0.3                                ...           8 years ago
  • 3.0.2                                ...           8 years ago
  • 3.0.1                                ...           8 years ago
  • 3.0.0                                ...           8 years ago
  • 3.0.0-beta.5                                ...           8 years ago
  • 3.0.0-beta.4                                ...           8 years ago
  • 3.0.0-beta.3                                ...           8 years ago
  • 3.0.0-beta.2                                ...           8 years ago
  • 3.0.0-beta.1                                ...           8 years ago
  • 2.2.7                                ...           9 years ago
  • 2.2.6                                ...           9 years ago
  • 2.2.5                                ...           10 years ago
  • 2.2.4                                ...           10 years ago
  • 2.2.3                                ...           10 years ago
  • 2.2.2                                ...           10 years ago
  • 2.2.1                                ...           10 years ago
  • 2.2.0                                ...           10 years ago
  • 2.1.0                                ...           11 years ago
  • 2.0.1                                ...           11 years ago
  • 2.0.0                                ...           11 years ago
  • 1.0.6                                ...           11 years ago
  • 1.0.5                                ...           11 years ago
  • 1.0.3                                ...           11 years ago
  • 1.0.2                                ...           11 years ago
  • 1.0.1                                ...           11 years ago
  • 1.0.0                                ...           11 years ago
  • 0.3.1                                ...           11 years ago
  • 0.3.0                                ...           11 years ago
  • 0.2.2                                ...           11 years ago
  • 0.2.1                                ...           11 years ago
  • 0.2.0                                ...           11 years ago
  • 0.1.5                                ...           11 years ago
  • 0.1.4                                ...           11 years ago
  • 0.1.3                                ...           11 years ago
  • 0.1.2                                ...           11 years ago
  • 0.1.0                                ...           11 years ago
  • 0.0.4                                ...           11 years ago
  • 0.0.3                                ...           11 years ago
  • 0.0.2                                ...           11 years ago
  • 0.0.1                                ...           11 years ago
Downloads
Total 411
Today 0
This Week 11
This Month 256
Last Day 0
Last Week 74
Last Month 21
Dependencies (0)
None
Dev Dependencies (25)

© 2010 - cnpmjs.org x YWFE | Home | YWFE