Simplest way to add fontawesome to spfx webpart

Do this on the top of you tsx file

import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import * as fontawesome from '@fortawesome/free-solid-svg-icons';

Then put this in your render function

<FontAwesomeIcon icon={fontawesome.faSearch} size="1x" />

Or

import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { library } from '@fortawesome/fontawesome-svg-core'
import * as fontawesome from '@fortawesome/free-solid-svg-icons';
import { fas } from '@fortawesome/free-solid-svg-icons';
library.add(fas);
<FontAwesomeIcon icon={"coffee" as any} size="1x" />

Leave a Reply

Your email address will not be published. Required fields are marked *