react-fontawesome icon indicating copy to clipboard operation
react-fontawesome copied to clipboard

Better React documentation: need to know icon's name + where to import from

Open aindriu80 opened this issue 6 years ago • 9 comments

hi,

I'm using react-fontawesome in a React project - its its a bit awkward compared to html... I don't know the correct name of the icon to use, or where to import the icon from.

Take the star : https://fontawesome.com/icons/star?style=regular

to use the star in html you use: <i class="fas fa-star"></i>

But what is it supposed to be in React ?

component:

import { faHome } from "@fortawesome/free-solid-svg-icons";

<div>
    <FontAwesomeIcon icon={faStar} />
</div>

And put in the imports into App.js to use :

import { library } from '@fortawesome/fontawesome-svg-core'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faIgloo } from '@fortawesome/free-solid-svg-icons'

It could be clearer what name to use for an icon in a component and what library to import in order to use that icon.

aindriu80 avatar Dec 20 '18 22:12 aindriu80

It's honestly so confusing.

jmayergit avatar Apr 04 '19 07:04 jmayergit

how did you even figure that much out lol i have no idea what i'm doing

blatde91 avatar May 24 '19 19:05 blatde91

5 minutes in to setting this up for a React project and had the same thought- where's the documentation to show what icon is in what library?

BenQuirk avatar Aug 06 '19 14:08 BenQuirk

@BenQuirk when you say "what icon is in what library", what do you mean? Like pro vs free? Solid vs regular vs light? Someone correct me if I'm wrong, but I believe that solid, regular, and light all include all the icons (not brands, of course). Just a matter of pro vs free. The pro versions have all the icons so there's no need to look up where anything lives. If not pro, then yeah I guess you do need to look it up, but it's visible from both the icon search results page (grayed out or not, and hovering over pro says "PRO") and the single icon page (right side of the page).

That being said, I do rely on TS auto import for FontAwesomeIcon because I can never remember if it's default or named export and if it's fontawesome-svg-core or react-fontawesome 😄.

elramus avatar Aug 06 '19 18:08 elramus

@elramus I ended up using React-Icons (https://alligator.io/react/react-icons-open-source-icons/) because the instructions made it look so easy. :)

BenQuirk avatar Aug 06 '19 19:08 BenQuirk

I have the same issue. I need to use all of these icons: https://use.fontawesome.com/releases/v5.0.9/css/all.css

But I have no idea how to import all of these. Does anyone have any idea? I would appreciate some hints.

Dror-Bar avatar Jun 28 '20 14:06 Dror-Bar

What about using faStar from both "free-solid-svg-icons" and "free-regular-svg-icons".

import { faStar } from '@fortawesome/free-solid-svg-icons' //no-outline import { faStar } from '@fortawesome/free-regular-svg-icons' //outline

I need to use both in the same component and isnt posible.

JasonParra avatar Aug 14 '20 19:08 JasonParra

you can copy the name you need from here: https://react-icons.github.io/react-icons/icons?name=fa

nirossss avatar Aug 20 '20 23:08 nirossss

definitely a more user-friendly implementation of fontawesome, thanks !!!

JasonParra avatar Aug 21 '20 01:08 JasonParra