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 |
|
10 | 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.
|
11 |
|
12 | ## Installation
|
13 |
|
14 | ```js
|
15 | npm install react-icons --save
|
16 | ```
|
17 |
|
18 | ## Usage
|
19 |
|
20 | ```jsx
|
21 | import { FaBeer } from 'react-icons/fa';
|
22 |
|
23 | class 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 |
|
46 | You can add more icons by submitting pull requests or creating issues.
|
47 |
|
48 | ## Configuration
|
49 |
|
50 | You can configure react-icons props using [React context API](https://reactjs.org/docs/context.html).
|
51 |
|
52 | requirement React 16.3 or higher.
|
53 |
|
54 | ```jsx
|
55 | import { 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 |
|
64 | key|default|memo
|
65 | ---|---|---
|
66 | color|undefined(inherit)|
|
67 | size|1em|
|
68 | className|undefined|
|
69 | style|undefined|can overwrite size and color
|
70 | attr|undefined|overwritten by other attributes
|
71 |
|
72 | ## Migrate from version 2 -> 3
|
73 |
|
74 | ### Change import style
|
75 |
|
76 | Import path has changed. You need to rewrite from the old style.
|
77 |
|
78 | ```jsx
|
79 | // OLD IMPORT STYLE
|
80 | import FaBeer from 'react-icons/lib/fa/beer';
|
81 |
|
82 | class 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
|
91 | import { FaBeer } from 'react-icons/fa';
|
92 |
|
93 | class Question extends React.Component {
|
94 | render() {
|
95 | return <h3> Lets go for a <FaBeer />? </h3>
|
96 | }
|
97 | }
|
98 | ```
|
99 |
|
100 | Ending up with a large JS bundle? Check out [this issue](https://github.com/react-icons/react-icons/issues/154).
|
101 |
|
102 | ### Adjustment CSS
|
103 |
|
104 | From version 3, `vertical-align: middle` is not automatically given.
|
105 | Please use IconContext to specify className or style.
|
106 |
|
107 | example for global styling
|
108 |
|
109 | ```tsx
|
110 | <IconContext.Provider value={{ style: { verticalAlign: 'middle' } }}>
|
111 | ```
|
112 |
|
113 | example 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 |
|
127 | Dependencies on `@types/react-icons` can be deleted.
|
128 |
|
129 | ```
|
130 | $ npm remove @types/react-icons
|
131 | ```
|
132 |
|
133 | ## Contribute
|
134 |
|
135 | development
|
136 |
|
137 | ```
|
138 | yarn
|
139 | yarn submodule # fetch icon sources
|
140 | cd packages/react-icons
|
141 | yarn build
|
142 | ```
|
143 |
|
144 | scripts for run demo
|
145 |
|
146 | ```
|
147 | cd packages/react-icons
|
148 | yarn build
|
149 | cd ../demo
|
150 | yarn start
|
151 | ```
|
152 |
|
153 | run preview site
|
154 |
|
155 | ```
|
156 | cd packages/react-icons
|
157 | yarn build
|
158 | cd ../preview
|
159 | yarn start
|
160 | ```
|
161 |
|
162 | ## Tips
|
163 |
|
164 | ### SVG ?
|
165 |
|
166 | Svg is [supported](http://caniuse.com/#search=svg) by all major browsers.
|
167 |
|
168 | ### Why ES6 import and not fonts?
|
169 |
|
170 | 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.
|
171 |
|
172 |
|
173 | ### Related
|
174 |
|
175 | - [react-svg-morph](https://github.com/gorangajic/react-svg-morph/)
|
176 |
|
177 | ## Licence
|
178 |
|
179 | MIT
|
180 |
|
181 | * Icons are taken from the other projects so please check each project licences accordingly.
|