React-fontawesome: How to add far-star?

Created on 19 Apr 2020  路  16Comments  路  Source: FortAwesome/react-fontawesome

How can I show in my react project "far-star" icon (empty star icon with only borders)?

Most helpful comment

@francesco87 how did you solve that

Apologies if this has been answered but here is how I managed to work around this issue.

I used npm to install 'npm i --save @fortawesome/free-regular-svg-icons' & 'npm i --save @fortawesome/free-solid-svg-icons'. I then created a library so I could have two variations of one icon (faStar) and added both of them like so;

import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { library } from '@fortawesome/fontawesome-svg-core'
import { faStar as fasFaStar } from '@fortawesome/free-solid-svg-icons'
import { faStar as farFaStar } from '@fortawesome/free-regular-svg-icons'
import { faStarHalfAlt} from "@fortawesome/free-solid-svg-icons";
library.add(fasFaStar, farFaStar, faStarHalfAlt)

Hope this helps.

All 16 comments

Hi @francesco87 what have you tried so far?

importing '@fortawesome/free-solid-svg-icons' I found faStar and faStarHalfAlt but I can't found farStar it is the empty start with only border.

The regular style of the star icon is available from the @fortawesome/free-regular-svg-icons package. Try that and see if you can find what you need.

+1 instructions are not clear for far icons

+1 towards mending documentation although the package name itself is self-explanatory

Just adding to this, I feel the icons library that can be used is not clear at all. Docs need a bit more info in which icons can be used and provide links to its gallery if possible.

No solution provided yet ?

@mohdafzal330 what have you tried that isn't working?

@robmadole what have you tried that isn't working?

@robmadole , I did find any icon in react similar to fa-star-o

@mohdafzal330

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

@robmadole while importing faStar , it gives us filled star, But I need empty star

solved

Let me check

@francesco87 how did you solve that

@francesco87 how did you solve that

Apologies if this has been answered but here is how I managed to work around this issue.

I used npm to install 'npm i --save @fortawesome/free-regular-svg-icons' & 'npm i --save @fortawesome/free-solid-svg-icons'. I then created a library so I could have two variations of one icon (faStar) and added both of them like so;

import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { library } from '@fortawesome/fontawesome-svg-core'
import { faStar as fasFaStar } from '@fortawesome/free-solid-svg-icons'
import { faStar as farFaStar } from '@fortawesome/free-regular-svg-icons'
import { faStarHalfAlt} from "@fortawesome/free-solid-svg-icons";
library.add(fasFaStar, farFaStar, faStarHalfAlt)

Hope this helps.

Add regular styles first :
yarn add @fortawesome/free-regular-svg-icons

Import to a component:
import { faStar as farStar } from "@fortawesome/free-regular-svg-icons";

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mattgogerly picture mattgogerly  路  3Comments

johnnunns picture johnnunns  路  6Comments

michelecocuccio picture michelecocuccio  路  4Comments

tomhuze picture tomhuze  路  6Comments

Richard87 picture Richard87  路  5Comments