SCSS Partials: What They Are and How to Load Them

Quick Summary

  • An SCSS file named with a leading underscore, such as _variables.scss, is a partial that Sass never compiles into its own CSS file.
  • Load partials into a main file such as style.scss with @use, leaving out the leading underscore and the file extension.
  • With @use, partial members are namespaced by default, such as variables.$name, while the older @import is being phased out by Sass.

SCSS partials are files whose names start with an underscore, such as _variables.scss or _mixins.scss. Partials usually hold variables, mixins or the styles for one part of a site, and you pull them into a main file like style.scss.

How partials differ from main files

The underscore tells Sass not to compile the file on its own. A partial doesn’t generate a CSS file or a CSS map file. A main file such as style.scss, without the underscore, compiles to style.css, plus a map file if source maps are turned on.

To use a partial, load it from the main file with @use, or the older @import, which Sass is phasing out. You can leave out the underscore and the file extension: @use 'variables'; loads _variables.scss. With @use, the partial’s members are namespaced by default, so a variable is referenced as variables.$name.

This lets you split your styles into small, organized files and still ship a single CSS file. The 7-1 Sass folder structure is one common way to organize those partials.

Share on X (opens in a new tab) Share on LinkedIn (opens in a new tab) Share on Facebook (opens in a new tab)

ChatGPT (opens in a new tab) Claude (opens in a new tab) Gemini (opens in a new tab) Perplexity (opens in a new tab) Grok (opens in a new tab)

More Insights

See More