Import Icons
Ready to reference icons? Here’s a primer on Font Awesome icon naming and how to import from icon content packages.
Referencing Icons
We recommend referencing icons in your HTML with a dedicated element you’ll use only for icons. We find the <i>
tag perfect for the job. That element will contain: 1) Font Awesome specific style prefix (e.g. fas
), and 2) the icon’s name (prefixed with fa-
) you want to display.
In Font Awesome 6, Font Awesome includes 6 different styles - Solid, Regular, Light, Duotone, and Brands. Here’s a break down of each’s use and availability.
Style | Prefix | Code | Example | Availability |
---|---|---|---|---|
Solid | fas | <i class="fas fa-flag"></i> | Free | |
Regular | far | <i class="far fa-flag"></i> | Pro only | |
Light | fal | <i class="fal fa-flag"></i> | Pro only | |
Duotone | fad | <i class="fad fa-flag"></i> | Pro only | |
Brands | fab | <i class="fab fa-font-awesome"></i> | Free |
Icon content “encoded” in JavaScript packages
The first version of Font Awesome used web fonts to encode icon data into a container the browser could use. In version 5, we added support for SVG which lets us do some fun things with icon data.
Scalable Vector Graphics (SVGs) are made up of text information that can include paths. We use the path data to draw the icons.
Here’s an example from our code
icon:
Since it’s just text, we can easily store this information in JavaScript files. This can be easier to deal with in some projects versus web font files and CSS.
Package names
Icon content packages are segmented by license and style:
Package name | Style | Prefix | Example | Availability |
---|---|---|---|---|
@fortawesome/free-solid-svg-icons | Solid | fas | Free | |
@fortawesome/free-regular-svg-icons | Regular | far | Free | |
@fortawesome/free-brands-svg-icons | Brands | fab | Free | |
@fortawesome/pro-solid-svg-icons | Solid | fas | Pro only | |
@fortawesome/pro-regular-svg-icons | Regular | far | Pro only | |
@fortawesome/pro-light-svg-icons | Light | fal | Pro only | |
@fortawesome/pro-duotone-svg-icons | Duotone | fad | Pro only |
Pro packages requires some extra configuration to allow NPM to install.
Icon names
JavaScript naming doesn’t use hyphens; it uses lower camel case. So here are some basic examples of
how imports
and requires
work.
Icon name | Version 4 name | Lower camel case | Notes on usage |
---|---|---|---|
address-book | fa-address-book | faAddressBook | The “B” is captialized after the hyphen |
facebook-f | fa-facebook | faFacebookF | It’s in the Brands style and this was renamed to facebook-f |
circle | fa-circle-o | faCircle | Outline versions of icons are now in the Regular and Light styles |
freebsd | fa-freebsd | faFreebsd | OCD-warning: we know it’s FreeBSD but consistency/guessability is the goal here |
Importing these specific icons:
Import all icons by using the prefix:
To import the same icon from different styles: