Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use same icon regular and solid type

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
  );
};
like image 750
mkysoft Avatar asked Sep 04 '26 05:09

mkysoft


2 Answers

Try this:

import { faBell } from '@fortawesome/free-solid-svg-icons/faBell';
import { faBell as anotherFaBell } from '@fortawesome/free-regular-svg-icons/faBell';
like image 107
Azamat Zorkanov Avatar answered Sep 06 '26 19:09

Azamat Zorkanov


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.

like image 30
mkysoft Avatar answered Sep 06 '26 20:09

mkysoft