Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

react-fontawesome

danawoodman153.9kMIT1.7.1TypeScript support: definitely-typed

A React component for the font-awesome icon library.

react, font-awesome, fontawesome, bootstrap, icons, fonts, icon, danawoodman, big, style, jsx, react-component, component

readme

react-fontawesome

styled with prettier Travis CI build status Dependency Status View on npm View on npm

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!

Install

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.

Using CDN version

The fastest way to get started is to import FontAwesome with a link tag in your page's <head>:

<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />

You can change the version number to use whatever version of FontAwesome you'd like.

Using with Webpack

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

var React = require('react')
var FA = require('react-fontawesome')

React.render(<FA name="rocket" />, 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

var React = require('react')
var FontAwesome = require('react-fontawesome')

var MyComponent = React.createClass({
  render: function() {
    return (
      <FontAwesome
        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

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 (
      <FontAwesome
        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:

<span class="font-awesome__fa___2otTb font-awesome__fa-rocket___lfSov font-awesome__super-crazy-colors___3k583"></span>

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.

License

MIT © Dana Woodman

changelog

Changelog

v.1.6.1

  • Remove support for iojs
  • Add test for node 6 and 7

v.1.6.0

  • Use prettier-eslint to auto-format code
  • Changed syntax to use ES6 class and package prop-types since the are both deprecated #41
  • Use prop-types package instead of deprecated React.PropTypes #40
  • Upgrade to node v7.8.0
  • Some cleanup

v.1.5.0

  • Move screenreader styles to separate file to fix build issues (see #32)

v1.4.0

  • Merged #30: Add support for aria screen reader support, thanks @Phyks

v1.3.1

  • Add documentation for overriding tag name

v1.3.0

  • Merged #28: Add ability to change base tag (default is still <span>), thanks @lucaskatayama
  • Cleaned up tests a bit
  • Version control lib directory since prepublish script is gone.

v1.2.0

  • Add CSS module support (#21, thanks @callumsmits!)
  • Simplify CSS tag creation code
  • Cleanup test suite

v1.1.0

  • Remove prepublish step so builds work on Windows

v1.0.0

We are production ready! 😬🤘🎉

  • Upgrade development node version
  • [Tests] Use the modern ReactDOM.render+findDOMNode APIs for React 15 (#10, thanks @ide!)
  • Filter which props are passed into the underlying span (#8, thanks @ide!)
  • Upgrade ESLint to v2 (#7, thanks @ide!)
  • Upgrade to Babel 6 (#6, thanks @ide!)

v0.3.0

  • Refactor to use new application structure
  • Use eslint
  • src folder for ES6/7 code ran through babel to lib
  • More helpful scripts
  • Simpler test
  • Less dependencies
  • Remove webpack
  • Add api docs
  • Updated readme

v0.2.5

  • Allow React to be 0.12 or greater, actually fixing #2.

v0.2.4

  • Relax React dependency which closes #2.

v0.2.3

  • Revert back to using lg instead of 1x for size.

v0.2.2

  • Update README
    • Add API reference.
    • General cleaup.

v0.2.1

  • Properly assign props to component.

v0.2.0

  • Reverting back to non-ES6 code to make more consumable.

v0.1.0

  • Move over to ES6 imports/emports
  • Use JSX instead of React.createElement