react-fontawesome
react-fontawesome copied to clipboard
How add far icons with the same name in fas icon to library
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']} />
You have two options:
- Use import aliases (as my example below shows)
- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import
- 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 👍🏼 😁