Using FortAwesome icons in PrimeReact Button

UI Components for React
Post Reply
raquel.mariz
Posts: 1
Joined: 13 Nov 2019, 15:09

13 Nov 2019, 16:02

Hello.

Since PrimeIcons has very few options that don't suit my needs, I decided to use FortAwesome in my project.

The problem is, even installing the module, the component Button ignores the icon property referring to the fort awesome icon.

Here is what I tried so far:

In App.tsx, I add the icon to the library component, so I can refer to the icon as a string:

Code: Select all

import {library} from '@fortawesome/fontawesome-svg-core';
import {faCoffee} from '@fortawesome/free-solid-svg-icons';

library.add(faCoffee);
Then I tried to use it in the prime react Button:

Code: Select all

<Button
            onClick={this.pauseButton}
            icon="coffee"
        />
However, no icon is rendered.

If I add the component of FontAwesome alone, the icon is rendered, so I know that my initial installation and setup of the module is correct.

Code: Select all

<FontAwesomeIcon icon="coffee" />
I also tried to do the following but to no avail:

Code: Select all

 <Button
            onClick={this.pauseButton}
            icon="coffee"
        >
	<FontAwesomeIcon icon="coffee" />
</Button>
Does anyone have a workaround? Is it possible to use FortAwesome with PrimeReact? Thank you in advance!

Post Reply

Return to “PrimeReact”

  • Information
  • Who is online

    Users browsing this forum: Shraunixc and 4 guests