Kit Package API
Font Awesome Kits can now be installed using npm-compatible package managers. Learn about what’s included and how to use the package in JavaScript and other applications.
What’s in the package
Asset | Location | What it’s good for |
---|---|---|
CSS | css/* | StyleSheets ready to work in any modern browser using the files in webfonts directory |
Less | less/* | Less files using the webfonts directory |
SCSS | scss/* | SCSS (Sass) files using the webfonts directory |
Webfont Files | webfonts/* | WOFF2 and TTF webfont files for use with CSS, Less, and SCSS |
Auto loading JavaScript | js/* | Easier to use JavaScript files for including in <script> tags directly in the browser using SVG + JS technology |
ESM & CommonJS JavaScript | modules/* | SVG Core-compatible JavaScript files suitable for use with build tools, JS frameworks, or <script type="module"> using SVG + JS technology |
SVG Sprites | sprites/* | SVG Sprites for all icons |
SVG Files | svg/* | Individual SVG files for all icons |
Data files | metadata/* | JSON and Yaml files containing icon data |
Using the JavaScript API
byPrefixAndName[prefix][iconName]
This object contains all icons in a Kit. If you’ve subsetted a Kit this can be an easy to understand to use.
Replace KIT_CODE with your Pro Kit unique token
If you’ve added the “house icon” to your Kit, you could do the following.
Objects from byPrefixAndName
are organized by prefix, then icon name.
Objects With individual icon objects shaped like this.
Prefix
The prefix fas
is one of the following.
Kit Custom Family
Style | Availability | Prefix | Looks like |
---|---|---|---|
Kits | Pro Plan | fak | Any icon that you upload |
Kits Duotone | Pro Plan | fakd | Any icon that you upload |
Classic Family
Style | Availability | Prefix | Looks like |
---|---|---|---|
Solid | Free Plan | fas | |
Regular | Pro only | far | |
Light | Pro only | fal | |
Thin | Pro only | fat | |
Brands | Free Plan | fab |
Duotone Family
Style | Availability | Prefix | Looks like |
---|---|---|---|
Solid | Pro only | fad | |
Regular | Pro only | fadr | |
Light | Pro only | fadl | |
Thin | Pro only | fadt |
Sharp Family
Style | Availability | Prefix | Looks like |
---|---|---|---|
Solid | Pro only | fass | |
Regular | Pro only | fasr | |
Light | Pro only | fasl | |
Thin | Pro only | fast |
Sharp Duotone Family
Style | Availability | Prefix | Looks like |
---|---|---|---|
Solid | Pro only | fasds | |
Regular | Pro only | fasdr | |
Light | Pro only | fasdl | |
Thin | Pro only | fasdt |
all[]
All is an array of every icon for a Kit. This is best if the Kit you are using is using custom subsetting.
The most useful way to use all
is to pair it with the SVG Core Library. The
library allows you to register icons you wish to use and look them up in a
variety of ways through other APIs and libraries.
The individual icons in the all
Array are just like the objects returned from byPrefixAndName
.
Icon packs
One step down from using all
is to import icons by their family and style.
Icon packs are objects keyed from icon names. But the icon names are prefixed
with fa
and camel-cased. So square-check
becomes faSquareCheck
. Since
variable names in JavaScript cannot begin with numbers that’s why you see
everything starting with fa
.
Imports
Kit Custom Family
Style | Import |
---|---|
Kits | import { fak } from '@awesome.me/kit-KIT_CODE/icons' |
Kits Duotone | Not yet available but coming soon! |
Classic Family
Style | Import |
---|---|
Solid | import { fas } from '@awesome.me/kit-KIT_CODE/icons' |
Regular | import { far } from '@awesome.me/kit-KIT_CODE/icons' |
Light | import { fal } from '@awesome.me/kit-KIT_CODE/icons' |
Thin | import { fat } from '@awesome.me/kit-KIT_CODE/icons' |
Brands | import { fab } from '@awesome.me/kit-KIT_CODE/icons' |
Duotone Family
Style | Import |
---|---|
Solid | import { fad } from '@awesome.me/kit-KIT_CODE/icons' |
Regular | import { fadr } from '@awesome.me/kit-KIT_CODE/icons' |
Light | import { fadl } from '@awesome.me/kit-KIT_CODE/icons' |
Thin | import { fadt } from '@awesome.me/kit-KIT_CODE/icons' |
Sharp Family
Style | Import |
---|---|
Solid | import { fass } from '@awesome.me/kit-KIT_CODE/icons' |
Regular | import { fasr } from '@awesome.me/kit-KIT_CODE/icons' |
Light | import { fasl } from '@awesome.me/kit-KIT_CODE/icons' |
Thin | import { fast } from '@awesome.me/kit-KIT_CODE/icons' |
Sharp Duotone Family
Style | Import |
---|---|
Solid | import { fasds } from '@awesome.me/kit-KIT_CODE/icons' |
Regular | import { fasdr } from '@awesome.me/kit-KIT_CODE/icons' |
Light | import { fasdl } from '@awesome.me/kit-KIT_CODE/icons' |
Thin | import { fasdt } from '@awesome.me/kit-KIT_CODE/icons' |
Individual icons
You can import individual icons. This has the advantage of being tree-shakable for keeping your bundles small.
Imports
Kit Custom Family
Style | Import |
---|---|
Kits | import { faMyIcon } from '@awesome.me/kit-KIT_CODE/icons/kit/custom' |
Kits Duotone | Not yet available but coming soon! |
Classic Family
Style | Import |
---|---|
Solid | import { faHouse } from '@awesome.me/kit-KIT_CODE/icons/classic/solid' |
Regular | import { faHouse } from '@awesome.me/kit-KIT_CODE/icons/classic/regular' |
Light | import { faHouse } from '@awesome.me/kit-KIT_CODE/icons/classic/light' |
Thin | import { faHouse } from '@awesome.me/kit-KIT_CODE/icons/classic/thin' |
Brands | import { faHouse } from '@awesome.me/kit-KIT_CODE/icons/classic/brands' |
Duotone Family
Style | Import |
---|---|
Solid | import { faHouse } from '@awesome.me/kit-KIT_CODE/icons/duotone/solid' |
Regular | import { faHouse } from '@awesome.me/kit-KIT_CODE/icons/duotone/regular' |
Light | import { faHouse } from '@awesome.me/kit-KIT_CODE/icons/duotone/light' |
Thin | import { faHouse } from '@awesome.me/kit-KIT_CODE/icons/duotone/thin' |
Sharp Family
Style | Import |
---|---|
Solid | import { faHouse } from '@awesome.me/kit-KIT_CODE/icons/sharp/solid' |
Regular | import { faHouse } from '@awesome.me/kit-KIT_CODE/icons/sharp/regular' |
Light | import { faHouse } from '@awesome.me/kit-KIT_CODE/icons/sharp/light' |
Thin | import { faHouse } from '@awesome.me/kit-KIT_CODE/icons/sharp/thin' |
Sharp Duotone Family
Style | Import |
---|---|
Solid | import { faHouse } from '@awesome.me/kit-KIT_CODE/icons/sharp-duotone/solid' |
Regular | import { faHouse } from '@awesome.me/kit-KIT_CODE/icons/sharp-duotone/regular' |
Light | import { faHouse } from '@awesome.me/kit-KIT_CODE/icons/sharp-duotone/light' |
Thin | import { faHouse } from '@awesome.me/kit-KIT_CODE/icons/sharp-duotone/thin' |
Troubleshooting
TypeScript
If you run into import errors when using TypeScript you may need to adjust your TypeScript config.
A common error caused by having the wrong moduleResolution
is this.
To fix this, go into your tsconfig.json
file and make sure the moduleResolution
is set to value supported by the kit package.
Options | |
---|---|
nodenext | Recommended |
bundler | Also supported if nodenext does not work for you for some reason. |
node16 | Supported but not recommended because it is currently the same as nodenext and nodenext is forward looking and will be updated to support new Node.js module resolution features as they are added. |
Unsupported | |
Unsupported | |
Unsupported |
Note about incompatible TypeScript defaults
Your TypeScript implementation may default to an incompatible module
or moduleResolution
option. For example, as of TypeScript 5.4.2
a new project will default to using module: commonjs
and will not specify moduleResolution
. Unfortunately, when module
is “commonjs”, then the default moduleResolution
is “node10”, equivalent to “node”, which is not supported.
For more information about the moduleResolution
setting, see the official TypeScript docs.
TypeScript + SVG Core APIs
Currently there two functions in the API from @fortawesome/fontawesome-svg-core
that are affected by a Kit Package.
Because the Kit Package can have a subset of Font Awesome icons or even custom uploaded icons, the TypeScript definitions need to be modified to be aware of these types.
Here, we can see TypeScript is reporting errors with the following code.
This can be pretty confusing the first time you run into it. TypeScript is
basically telling us that the arguments for icon()
or findIconDefinition()
have been defined in the @fortawesome/fontawesome-common-types
package. That
package is generic and includes every available Font Awesome icon. It’s not
aware of the icons in your Kit.
We can use Module Augmentation to update the definition for both functions.
This will fix things up. You can place the declare module
in any module (according to our testing) and you only need to add it once.
404 Error
If you get this error:
Try running the update command before running the install command.