fontawesome react code example

Example 1: npm font awesome

npm install --save font-awesome

Example 2: react fontawesome

npm i --save @fortawesome/fontawesome-svg-core
npm install --save @fortawesome/free-solid-svg-icons
npm install --save @fortawesome/react-fontawesome

npm install --save @fortawesome/free-brands-svg-icons
npm install --save @fortawesome/free-regular-svg-icons

Example 3: font awesome in react

$ npm i --save @fortawesome/fontawesome-svg-core  @fortawesome/free-solid-svg-icons @fortawesome/react-fontawesome

Example 4: using react-fontawesome

//using fontawesome inside of react project
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import {faSearch} from "@fortawesome/free-solid-svg-icons";

const MyComponent = () => {
  return (<div>
          //fontawesome usage
          <FontAwesomeIcon icon={faSearch} />
        </div>);
}
export default MyComponent ;

Example 5: react font awesome

import ReactDOM from 'react-dom'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faCoffee } from '@fortawesome/free-solid-svg-icons'

const element = <FontAwesomeIcon icon={faCoffee} />

ReactDOM.render(element, document.body)

Example 6: how to use react-fontawesome

npm install --save @fortawesome/free-brands-svg-icons  npm install --save @fortawesome/free-regular-svg-icons