Looking to use Font Awesome icons as SVG Sprites? We’ve got ‘em. And there’s no need to load JavaScript code at runtime.
We’ll cover the basic of adding icons as SVG sprites, and cover the sticking points of using SVG sprites to help you ensure your projects are a good fit for their use.
To add icons from a sprite file, follow these steps:
Grab the sprite file for the style or styles you want to use.
Place this file with the rest of your static files, like CSS or images, in your project.
In the body of your document, call the individual icon by name in the sprite file for the style you want to use. Make sure the path correctly points to where you placed the sprite files, and they are hosted on the same server!
Optionally, you can add accessibility hints via aria attributes to either hide the icon from assistive technology, or give it a proper human readable name.
Here’s some examples of how you can call icons in a variety of styles:
<header>
<ul>
<li>
<!-- referencing a couple of solid style icons -->