- Look for
GIST NOTE
comment in the files I posted - Install FontAwesome SVG packages via npm/yarn
- Copy files in this gist into your project & modify to your needs
- Run
bin/console app:icons
any time you change the set of icons you need. It will update the Twig extension and the sprite file. Assuming your icon set is fairly stable, this manual step might not bother you.
If the steps above worked, you should be now able to refer to your icons in Twig, for example {{ regularIcon('xmark') }}
.
I found it super useful to use those enums as it enables static code analysis, discovery of dangling icons and so on. If you want to render the backed enum in twig directly, use {{ enumIcon(iconVariable) }}
.
The enumIcon
, regularIcon
etc functions have a couple of arguments, check out the Twig extension what are they all about.