A React component for the font-awesome icon library.
npm install react-fontawesome




> A React component for the font-awesome icon library.
If you are using Font Awesome v5+, please use the official React component!. react-fontawesome does not support FontAwesome v5!
``bash`
npm install --save react-fontawesome
_Note: This component does not include any of the Font Awesome CSS or fonts, so you'll need to make sure to include those on your end somehow, either by adding them to your build process or linking to CDN versions._
The fastest way to get started is to import FontAwesome with a link tag in your page's
:`html
`You can change the version number to use whatever version of FontAwesome you'd like.
$3
If you're using WebPack, you will need to install FontAwesome, import the FontAwesome Sass/Less, and configure the font path. Please see this blog post on how to get Webpack and FontAwesome working together.
Usage
`js
var React = require('react')
var FA = require('react-fontawesome')React.render( , document.body)
`Features
* No dependencies (other than React)
* Simple API that mirrors Font Awesome's class names.
* Supports all Font Awesome modifiers (see API below).
* Make use of Css Modules
* Add your own
classNames, styles and other props (all additional props are passed directly to the component).Examples
Regular usage
`js
var React = require('react')
var FontAwesome = require('react-fontawesome')var MyComponent = React.createClass({
render: function() {
return (
className="super-crazy-colors"
name="rocket"
size="2x"
spin
style={{ textShadow: '0 1px 0 rgba(0, 0, 0, 0.1)' }}
/>
)
},
})
`With the use of CSS Modules
`js
import React from 'react'
import FontAwesome from 'react-fontawesome'
import faStyles from 'font-awesome/css/font-awesome.css'var MyComponent = React.createClass({
render: function() {
return (
className="super-crazy-colors"
name="rocket"
cssModule={faStyles}
size="2x"
spin
style={{ textShadow: '0 1px 0 rgba(0, 0, 0, 0.1)' }}
/>
)
},
})
`The above will create output like this:
`
`API
See the API docs for full documentation.
Contributing
Pull requests welcome!
Run the test suite with
npm test and format your code with npm run format. Make sure tests are passing and that you write tests for new features and document changes to the API with updates to the JSDocs.Before you submit your pull request, run
npm run dist` to build the project and commit the changes.MIT © [Dana Woodman][author]
[author]: https://github.com/danawoodman