Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use outlined icons with react-fontawesome?

Basically I'm trying to use two icons:

  1. <i class="fas fa-heart"></i> Solid heart icon

  2. <i class="far fa-heart"></i> Regular heart icon (outlined)

The first one I got with the following code:

<FontAwesomeIcon icon={faHeart} />

How can I get the second one?

like image 638
Pablo Darde Avatar asked Nov 28 '19 15:11

Pablo Darde


People also ask

How do you put a border on Font Awesome icons?

To increase fa-border-all font awesome icon size, use the fa-lg (33% increase), fa-2x, fa-3x, fa-4x, or fa-5x classes along with icon class fa-border-all.

How to use Font Awesome icons in React project?

To use font awesome icons in easy way into your React project use react-icon library which not only provides support for font awesome but as well as provides for Bootstrap icons , Heroicons and more. step 2. Import a icon like this - Step 3. Use it something like this -

How to use fontawesome in React Native?

To use FontAwesome in React Native you need to download the fonts as a TTF file and have to include in your project the same as I have described below. We are going to use Regular, Solid, and Brand Icons in this example so please click on the below URL to download TTF file for the same.

How do I use Font Awesome icons in my App?

Font Awesome's import code is import { IconName } from "react-icons/fa";. Follow these steps below to use the Font Awesome icons in your app. In App.js, paste the import code at the top of the file after the React import code Go back to the React icons page and choose any icon from the Font Awesome icons

How do I add icons to my react app?

There are a few ways to add icons when using React. The easiest way is to use Dynamic Icon Importing which automatically imports the icons you're using - and only the icons you're using. But you can choose other methods that allow you to explicitly add individual icons or add icons to a global library.


1 Answers

After some reading in the react-fontawesome docs I figured out how to do outlined icons.

For the first one I need the package @fortawesome/free-solid-svg-icons Then I need to import the icons as the following:

import { faHeart, faTrash } from '@fortawesome/free-solid-svg-icons'

The second one, I need the package @fortawesome/free-regular-svg-icons

Then I just import the following.

import { faHeart as farHeart } from '@fortawesome/free-regular-svg-icons'

That's it!

like image 115
Pablo Darde Avatar answered Sep 27 '22 17:09

Pablo Darde