React-fontawesome: How add far icons with the same name in fas icon to library

Created on 23 Aug 2018  路  5Comments  路  Source: FortAwesome/react-fontawesome

For example the icon File. There are a option fas and another far.

I want know if is possible import faFile from 'solid' and 'regular' and add both to my library. and before use

like this: or

Most helpful comment

You have two options:

  1. Use import aliases (as my example below shows)
  2. Create multiple files for library imports (e.x. solid-icons.js reg-icons.js) so the import names can be the same
import { library } from '@fortawesome/fontawesome-svg-core'
import { faFile } from '@fortawesome/free-solid-svg-icons'
import { faFile as faFileRegular } from '@fortawesome/free-regular-svg-icons'

library.add(faFile, faFileRegular)

All 5 comments

You have two options:

  1. Use import aliases (as my example below shows)
  2. Create multiple files for library imports (e.x. solid-icons.js reg-icons.js) so the import names can be the same
import { library } from '@fortawesome/fontawesome-svg-core'
import { faFile } from '@fortawesome/free-solid-svg-icons'
import { faFile as faFileRegular } from '@fortawesome/free-regular-svg-icons'

library.add(faFile, faFileRegular)

Thank you. It worked.

Hey @paustint - can you give an example of importing from a separate file please?

I'm having issues importing/exporting the icons from a separate file and then importing into my component.

Thanks in advance!

@robhadfield This is how I do it. I think it's the perfect solution.

https://gist.github.com/stevensacks/0a88e2aaedbb423021189f9e9ac51d91

I put these in a folder called /font-awesome and then just

import fontAwesome from './font-awesome`;

@stevensacks - that's almost identical to how I ended up doing it 馃憤馃徏 馃榿

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lomse picture lomse  路  5Comments

michelecocuccio picture michelecocuccio  路  4Comments

lehresman picture lehresman  路  6Comments

skovy picture skovy  路  5Comments

gtkatakura-bysoft picture gtkatakura-bysoft  路  5Comments