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

How add far icons with the same name in fas icon to library

Open henfreire opened this issue 6 years ago • 5 comments

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: <FontAwesomeIcon icon={['far', 'file']} /> or <FontAwesomeIcon icon={['fas', 'file']} />

henfreire avatar Aug 23 '18 20:08 henfreire

You have two options:

  1. Use import aliases (as my example below shows)
    • https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import
  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)

paustint avatar Aug 23 '18 22:08 paustint

Thank you. It worked.

henfreire avatar Aug 24 '18 11:08 henfreire

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 avatar Oct 03 '18 09:10 robhadfield

@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 avatar Oct 29 '19 06:10 stevensacks

@stevensacks - that's almost identical to how I ended up doing it 👍🏼 😁

robhadfield avatar Oct 29 '19 09:10 robhadfield