Skip to content

Sass (SCSS)

Are you using Sass as a CSS preprocessor in your project? No problemo, Font Awesome has an SCSS version if you’d prefer to import our styling into your workflow.

We’ll cover the basics of picking the SCSS files you’ll need for your project, adding Font Awesome to your compile, inject code into a class with Mixins, and more.

You’ll find everything you need in the scss directory of the Font Awesome download. Below is the list of files made specifically for SCSS. You can add them all to your project or pick just the ones you need.

FilesWhat They Do
fontawesome.scssMain Font Awesome compile
_animated.scssanimated icon support styling
_bordered.scssbordered icon support styling
_pulled.scsspulled icon support styling
_core.scssBase icon reference class syntax and definition
_widths.scssIcon Canvas width support styling
_icons.scssAll icon definitions
_list.scssicons in a list support styling
_mixins.scssUtilities used throughout styling/icon definitions
_rotated-flipped.scssrotating icons support styling
_sizing.scssicon sizing support styling
_stacked.scssstacking icons support styling
_variables.scssWhere variables are defined that are used throughout styling
_custom-icons.scssincludes custom icons in a Kit Download (if you’re using one)
Individual icon style partialsSupport styling and configuration for each icon style

Copy the scss folder into your project. Then copy the webfonts folder into your project, where your static files get served.

In your main SCSS compile file, you’ll want to do the following things:

Any Font Awesome variable defined in the _variables.scss can be overriden when you load it using the @use rule. You’ll want to override the $font-path variable to point to where you placed the webfonts folder.

@use './fontawesome/variables' with (
// customizing $font-path - make sure it points to where your webfonts are stored in your project
$font-path: '../webfonts',
);

Next, load Font Awesome’s Core styling and make Font Awesome’s helpers (mixins, functions, and variables) available via the _fa.scss partial which leverages Sass’s @forward rule.

// customize variables
@use './fontawesome/variables' with (
// customizing $font-path - make sure it points to where your webfonts are stored in your project
$font-path: '../webfonts',
);
// load Font Awesome core
@use './fontawesome/fontawesome';
// load and make available Font Awesome helpers (mixins, functions, and variables)
@use './fontawesome/fa' as fa;

Each icon style is available via an individual SCSS partial. Adds the files for the icon styles you plan to use in your project.

// customize variables
@use './fontawesome/variables' with (
// customizing $font-path
$font-path: '../webfonts',
);
// load Font Awesome core
@use './fontawesome/fontawesome';
// load and make available Font Awesome helpers (mixins, functions, and variables)
@use './fontawesome/fa' as fa;
// load individual Font Awesome styles - add only the ones you plan to use in your project. Here is an example of a project using Classic Solid, Brands, Duotone Solid, and Sharp Duotone Solid icons...
@use './fontawesome/solid' as fa-solid;
@use './fontawesome/brands' as fa-brands;
@use './fontawesome/duotone' as fa-duotone;
@use './fontawesome/sharp-duotone' as fa-sharp-duotone;

Once you’ve added the imports above and have your compiled CSS that includes Font Awesome set up and referenced in your project, you can add icons to your project’s HTML.

Here’s an example of how to reference icons with your compiled and hosted CSS:

<head>
<!--load your compiled CSS (including Font Awesome) -->
<link
href="/your-path-to-your-compiled-css-including-fontawesome/file.css"
rel="stylesheet"
/>
</head>
<body>
<!-- This example uses <i> element with:
1. the `fa-solid` style class for solid style
2. the `user` icon with the `fa-` prefix -->
<i class="fa-solid fa-user"></i>
<!-- Or you can use a <span> element, with classes applied in the same way -->
<span class="fa-solid fa-user"></span>
</body>

If you are writing custom styling in the same file as your compile, you can use the namespaced fa partial to leverage the Font Awesome variables, mixins, and utilities like so:

// CASE: your main compile file
// load Font Awesome core
@use './fontawesome/fontawesome';
// load and make available Font Awesome helpers (mixins, functions, and variables)
@use './fontawesome/fa' as fa;
// the rest of your custom Sass/SCSS...

If you are writing custom styling in other partials that your main compile is loading, you’ll need to load the Font Awesome variables, mixins, and utilities yourself in the file that requires any of them.

// CASE: partial file that your main compile loads
// load Font Awesome helpers (mixins, functions, and variables) as needed
@use './fontawesome/variables' as fa-v;
@use './fontawesome/mixins' as fa-m;
@use './fontawesome/functions' as fa-f;
// the rest of your partial's custom Sass/SCSS...

Once loaded, you can use any of Font Awesome’s variables in your custom rules.

// load Font Awesome core
@use './fontawesome/fontawesome';
// load and make available Font Awesome helpers (mixins, functions, and variables)
@use './fontawesome/fa' as fa;
// custom rules
.same-width-as-fa-icons {
// using Font Awesome's fa-width variable to set the width of an element
width: fa.$fw-width;
}

Once loaded, you can use any of Font Awesome’s mixins in your custom rules.

// load Font Awesome core
@use './fontawesome/fontawesome';
// load and make available Font Awesome helpers (mixins, functions, and variables)
@use './fontawesome/fa' as fa;
// custom rules
.size-same-as-xl-icon {
// using Font Awesome's fa-size mixin to set the font-size of an element to the xl scale value
@include fa.fa-size(xl);
}

One of the more common cases for writing custom Sass/SCSS is to handle rendering icons using CSS pseudo-elements. This method is also useful when changing the HTML on your project is not an option.

Each individual style you load into your project’s compile includes a specific icon() mixin. These mixins handle the basic rendering that we bundle in our toolkit to make sure icons display perfectly. Along with that, they generate rules to render icon in the individual family + style.

Here’s an example building off of previous code snippets:

// CASE: your main compile file
// customize variables
@use './fontawesome/variables' with (
// customizing $font-path
$font-path: '../webfonts',
);
// load Font Awesome core
@use './fontawesome/fontawesome';
// load and make available Font Awesome helpers (mixins, functions, and variables)
@use './fontawesome/fa' as fa;
// load individual Font Awesome styles
@use './fontawesome/solid' as fa-solid;
@use './fontawesome/regular' as fa-regular;
@use './fontawesome/light' as fa-light;
@use './fontawesome/thin' as fa-thin;
@use './fontawesome/duotone' as fa-duotone-solid;
@use './fontawesome/brands' as fa-brands;
@use './fontawesome/sharp-solid' as fa-sharp-solid;
// Solid style of user
.user {
@include fa-solid.icon(fa.$var-user);
}
// Regular style of triangle-exclamation
.triangle-exclamation {
@include fa-regular.icon(fa.$var-triangle-exclamation);
}
// Light style of newspaper
.newspaper {
@include fa-light.icon(fa.$var-newspaper);
}
// Thin style of paintbrush-fine
.paintbrush-fine {
@include fa-thin.icon(fa.$var-paintbrush-fine);
}
// Duotone style of camera-retro
.camera-retro {
@include fa-duotone-solid.icon(fa.$var-paintbrush-fine);
}
// Sharp Solid style of trash
.trash {
@include fa-sharp-solid.icon(fa.$var-trash);
}
// Bluesky brand icon
.bluesky {
@include fa-brands.icon(fa.$var-bluesky);
}

Did you know you can download a Kit to compile and host yourself just like you do with Font Awesome? To download your Kit, make sure the Kit’s version in Settings is set to use Version 7 (or if you selected a specific version, it needs to be at least 6.4). Then from the Set Up tab in your Kit, you’ll see the options for downloading. Your Kit download will contain all of the SCSS files noted above.

If you have custom icons in your Kit, they will be included as an additional files in your Kit download.

Path to the filesWhat the files do
/webfonts/custom-icons.woff2Custom icon font in WOFF2 format
/scss/_custom-icons.scssSass (SCSS) Preprocessor partial that handles the display of custom icons using Web Fonts

Here’s a simple example that follows the compile steps above along with custom icons:

// customize variables
@use './fontawesome/variables' with (
// customizing $font-path
$font-path: '../webfonts',
);
// load Font Awesome core
@use './fontawesome/fontawesome';
// load and make available Font Awesome helpers (mixins, functions, and variables)
@use './fontawesome/fa' as fa;
// load individual Font Awesome styles that you plan to use in your project
@use './fontawesome/solid' as fa-solid;
@use './fontawesome/brands' as fa-brands;
@use './fontawesome/duotone' as fa-duotone;
@use './fontawesome/sharp-duotone' as fa-sharp-duotone;
// load your custom icons
@use './fontawesome/custom-icons' as fa-custom-icons;

Font Awesome’s SCSS version also leverages several SCSS variables that allow for easier set-up and customization of our styling toolkit.

VariableWhat It Does
$css-prefixSets the prefix (default set to fa) used on all styling toolkit CSS rules (e.g. fa-lg) + icon reference classes (e.g. fa-user)
$styleSets the default icon style (using @font-face weight)
$familySets the default font-family used
$displaySets the display property (default set to inline-block) for rendered icons
$font-displaySets the font-display property for Font Awesome’s icon fonts
$fw-widthSets the width property for all fixed-width icons
$inverseSets the color property of .fa-inverse
$border-box-sizingSets the box-sizing property used in bordered icons
$border-colorSets the border-color property used in bordered icons
$border-paddingSets the padding property used in bordered icons
$border-radiusSets the border-radius property used in bordered icons
$border-styleSets the border-style property used in bordered icons
$border-widthSets the border-width property used in bordered icons
$li-widthSets the width property for fa-li elements when styling icons in a list icons
$li-marginSets the margin-right property for fa-li elements when styling icons in a list icons
$pull-marginSets the margin-left/margin-right property for pulled icons icons
$primary-opacitySets the opacity of a duotone icon’s primary layer
$secondary-opacitySets the opacity of a duotone icon’s secondary layer
$size-scale-baseSets the base step size that all other relative sizing steps are based on
$size-scale-2xsSets the size of step used when relatively sizing icons with .fa-2xs
$size-scale-xsSets the size of step used when relatively sizing icons with .fa-xs
$size-scale-smSets the size of step used when relatively sizing icons with .fa-sm
$size-scale-lgSets the size of step used when relatively sizing icons with .fa-lg
$size-scale-xlSets the size of step used when relatively sizing icons with .fa-xl
$size-scale-2xlSets the size of step used when relatively sizing icons with .fa-2xl
$stack-vertical-alignSets the vertical-align property of stacked icons
$stack-widthSets the width property of stacked icons
$stack-z-indexSets the z-index property of stacked icons
$font-pathSets the location of Font Awesome’s webfonts folder and assets.

Font Awesome’s SCSS leverages a small amount of mixins and functions to help render icons.

UtilityWhat It DoesArguments
fa-icon()Produces all of the base style set up for an icon’s rendering, plus configuration for a specific icon family and style$family — any valid font-family value
fa-size()Relatively adjusts the size of an icon using Font Awesome’s relative sizing styling and scale$font-size — any valid size value from the relative sizing scale
fa-content()A function to make referencing icons via the CSS content property a bit easier$var — Any valid icon-based variable (e.g. fa-content($fa-var-user);)
icon() found in individual icon style partialsIndividual Style-only mixins that produce all the base style set up for an icon’s rendering, plus configuration for a specific icon family and style.N/A - family and style are set explicitly with these