I try to use same icon regular and solid type in a react component. I can't load it with different name. Is there any way?
My icon loader:
import { faBell } from '@fortawesome/free-solid-svg-icons/faBell';
//import { faBell } from '@fortawesome/free-regular-svg-icons/faBell';
import { library } from '@fortawesome/fontawesome-svg-core';
export const loadIcons = () => {
library.add(
faBell
);
};
Try this:
import { faBell } from '@fortawesome/free-solid-svg-icons/faBell';
import { faBell as anotherFaBell } from '@fortawesome/free-regular-svg-icons/faBell';
I can get result with below:
Not need to import anything for usage:
<FontAwesomeIcon icon={['far', 'bell']} />
We need load icons to library:
import { faBell } from '@fortawesome/free-solid-svg-icons/faBell';
import { faBell as farBell } from '@fortawesome/free-regular-svg-icons';
import { library, IconDefinition } from '@fortawesome/fontawesome-svg-core';
export const loadIcons = () => {
library.add(faBell, farBell as IconDefinition);
};
My first founding cannot pass type script rules but working:
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faBell as faBellRegular } from '@fortawesome/free-regular-svg-icons/faBell';
<FontAwesomeIcon icon={faBellRegular} />
But I can't find any solution for adding icon to library and using it strandard method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With