UNPKG

4.07 kBMarkdownView Raw
1<img src="https://rawgit.com/gorangajic/react-icons/master/react-icons.svg" width="120" alt="React Icons">
2
3# [React Icons](https://react-icons.netlify.com)
4
5[![npm][npm-image]][npm-url]
6
7[npm-image]: https://img.shields.io/npm/v/react-icons.svg?style=flat-square
8[npm-url]: https://www.npmjs.com/package/react-icons
9
10Include 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.
11
12## Installation
13
14```js
15npm install react-icons --save
16```
17
18## Usage
19
20```jsx
21import { FaBeer } from 'react-icons/fa';
22
23class Question extends React.Component {
24 render() {
25 return <h3> Lets go for a <FaBeer />? </h3>
26 }
27}
28```
29
30## Icons
31
32- Font Awesome - https://fontawesome.com/
33 License: [CC BY 4.0 License](https://creativecommons.org/licenses/by/4.0/)
34- Ionicons - https://ionicons.com/
35 License: [MIT](https://github.com/ionic-team/ionicons/blob/master/LICENSE)
36- Material Design icons - http://google.github.io/material-design-icons/
37 License: [Apache License Version 2.0](https://github.com/google/material-design-icons/blob/master/LICENSE)
38- Typicons - http://s-ings.com/typicons/
39 License: [CC BY-SA 3.0](https://creativecommons.org/licenses/by-sa/3.0/)
40- Github Octicons icons - https://octicons.github.com/
41 License: [MIT](https://github.com/primer/octicons/blob/master/LICENSE)
42- Feather - https://feathericons.com/
43 License: [MIT](https://github.com/feathericons/feather/blob/master/LICENSE)
44
45
46You can add more icons by submitting pull requests or creating issues.
47
48## Configuration
49
50You can configure react-icons props using [React context API](https://reactjs.org/docs/context.html).
51
52requirement React 16.3 or higher.
53
54```jsx
55import { IconContext } from "react-icons";
56
57<IconContext.Provider value={{ color: "blue", className: "global-class-name" }}>
58 <div>
59 <FaFolder />
60 </div>
61</IconContext.Provider>
62```
63
64key|default|memo
65---|---|---
66color|undefined(inherit)|
67size|1em|
68className|undefined|
69style|undefined|can overwrite size and color
70attr|undefined|overwritten by other attributes
71
72## Migrate from version 2 -> 3
73
74### Change import style
75
76Import path has changed. You need to rewrite from the old style.
77
78```jsx
79// OLD IMPORT STYLE
80import FaBeer from 'react-icons/lib/fa/beer';
81
82class Question extends React.Component {
83 render() {
84 return <h3> Lets go for a <FaBeer />? </h3>
85 }
86}
87```
88
89```jsx
90// NEW IMPORT STYLE
91import { FaBeer } from 'react-icons/fa';
92
93class Question extends React.Component {
94 render() {
95 return <h3> Lets go for a <FaBeer />? </h3>
96 }
97}
98```
99
100Ending up with a large JS bundle? Check out [this issue](https://github.com/react-icons/react-icons/issues/154).
101
102### Adjustment CSS
103
104From version 3, `vertical-align: middle` is not automatically given.
105Please use IconContext to specify className or style.
106
107example for global styling
108
109```tsx
110<IconContext.Provider value={{ style: { verticalAlign: 'middle' } }}>
111```
112
113example for give global className
114
115```tsx
116// app.tsx
117<IconContext.Provider value={{ className: 'react-icons' }}>
118
119// app.css
120.react-icons {
121 vertical-align: middle;
122}
123```
124
125### TypeScript native support
126
127Dependencies on `@types/react-icons` can be deleted.
128
129```
130$ npm remove @types/react-icons
131```
132
133## Contribute
134
135development
136
137```
138yarn
139yarn submodule # fetch icon sources
140cd packages/react-icons
141yarn build
142```
143
144scripts for run demo
145
146```
147cd packages/react-icons
148yarn build
149cd ../demo
150yarn start
151```
152
153run preview site
154
155```
156cd packages/react-icons
157yarn build
158cd ../preview
159yarn start
160```
161
162## Tips
163
164### SVG ?
165
166Svg is [supported](http://caniuse.com/#search=svg) by all major browsers.
167
168### Why ES6 import and not fonts?
169
170With `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.
171
172
173### Related
174
175- [react-svg-morph](https://github.com/gorangajic/react-svg-morph/)
176
177## Licence
178
179MIT
180
181* Icons are taken from the other projects so please check each project licences accordingly.