Set up access to the Javascript API in your project.
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. fa-solid), and 2) the icon's name (prefixed with fa-) you want to display.
<!-- solid style of the question circle icon --><iclass="fa-solid fa-question-circle"></i><!-- regular style of the question circle icon --><iclass="fa-regular fa-question-circle"></i><!-- facebook brand icon--><iclass="fa-brands fa-facebook"></i><!-- facebook "f" brand icon--><iclass="fa-brands fa-facebook-f"></i>
<!-- solid style of the computer classic icon --><iclass="fa-solid fa-computer-classic"></i><!-- regular style of the computer classic icon --><iclass="fa-regular fa-computer-classic"></i><!-- light style of the computer classic icon --><iclass="fa-light fa-computer-classic"></i><!-- thin style of the computer classic icon --><iclass="fa-thin fa-computer-classic"></i><!-- duotone style of the computer classic icon --><iclass="fa-duotone fa-computer-classic"></i><!-- sharp solid style of the computer classic icon --><iclass="fa-sharp fa-solid fa-computer-classic"></i><!-- sharp regular style of the computer classic icon --><iclass="fa-sharp fa-regular fa-computer-classic"></i><!-- sharp light style of the computer classic icon --><iclass="fa-sharp fa-light fa-computer-classic"></i>
Families + Styles
There are three families of Font Awesome icons - each with a unique look, class name, and @font-face font-family. In both Font Awesome Classic and Sharp, there are five styles of Font Awesome icons. Here are some examples:
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.
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:
import{ library }from'@fortawesome/fontawesome-svg-core'import{ fas }from'@fortawesome/free-solid-svg-icons'import{ far }from'@fortawesome/free-regular-svg-icons'import{ fab }from'@fortawesome/free-brands-svg-icons'<!-- Add all icons to the library so you can use it in your page -->
library.add(fas, far, fab)
import{ library }from'@fortawesome/fontawesome-svg-core'import{ fas }from'@fortawesome/pro-solid-svg-icons'import{ far }from'@fortawesome/pro-regular-svg-icons'import{ fal }from'@fortawesome/pro-light-svg-icons'import{ fat }from'@fortawesome/pro-thin-svg-icons'import{ fad }from'@fortawesome/pro-duotone-svg-icons'import{ fass }from'@fortawesome/sharp-solid-svg-icons'import{ fasr }from'@fortawesome/sharp-regular-svg-icons'import{ fasl }from'@fortawesome/sharp-light-svg-icons'<!-- Add all icons to the library so you can use it in your page -->
library.add(fas, far, fal, fat, fad, fass, fasr, fasl)
To import the same icon from different styles:
import{ library }from'@fortawesome/fontawesome-svg-core'import{ faCircle as fasFaCircle }from'@fortawesome/free-solid-svg-icons'// ES Module "as" syntaximport{ faCircle as farFaCircle }from'@fortawesome/free-regular-svg-icons'
library.add(fasFaCircle, farFaCircle)
import{ library }from'@fortawesome/fontawesome-svg-core'import{ faTruck as fasTruck }from'@fortawesome/pro-solid-svg-icons'import{ faTruck as farTruck }from'@fortawesome/pro-regular-svg-icons'import{ faTruck as falTruck }from'@fortawesome/pro-light-svg-icons'import{ faTruck as fatTruck }from'@fortawesome/pro-thin-svg-icons'import{ faTruck as fadTruck }from'@fortawesome/pro-duotone-svg-icons'import{ faTruck as fassTruck }from'@fortawesome/sharp-solid-svg-icons'import{ faTruck as fasrTruck }from'@fortawesome/sharp-regular-svg-icons'import{ faTruck as faslTruck }from'@fortawesome/sharp-light-svg-icons'
library.add(fasTruck, farTruck, falTruck, fatTruck, fadTruck, fassTruck, fasrTruck, faslTruck)