sventastic
sventastic

Reputation: 45

How to import font-awesome in node.js to use in react.js?

I am working with node.js and react.js. I already imported my own css file like so:

import React from 'react';
import Modal from 'react-modal';
import './../App.css';

this works fine, but when I try to add font-awesome like so:

import './src/font-awesome-4.7.0/css/font-awesome.css'

then it doesn't work.

Am I doing something wrong? Or is there maybe another way?

Upvotes: 3

Views: 6676

Answers (1)

Mμ.
Mμ.

Reputation: 8542

Here's how i did it entirely in the front end react side:

  1. Include font awesome inside the <head> tag

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

    npm install --save react-fontawesome

  3. Import the file and use it in your react components

    import FontAwesome from 'react-fontawesome';
    
    // ..rest of your code
    <FontAwesome name="linkedin" size="2x"/>
    

Upvotes: 8

Related Questions