Faragiri

Learn Sass and preprocessors CSS

Which Sass features are now native, the one distinction that decides between a dollar variable and a custom property, and what a mixin still does that neither can.

4Sections
3Min read
4Depth

Recommended Before This

0 / 2

Sass had six features worth having and CSS has since taken back four of them.
What is left is the honest reason to still reach for it, and it is a much
shorter list than most projects assume.

  • Variables: now --rail: 220px and
    var(--rail), which Sass cannot match, because a custom property is
    live in the browser and can be changed by a media query, a class or a script
  • Nesting: now native, with the same
    & for the parent selector
  • Colour functions: now color-mix() and relative
    colour syntax, working at runtime on a custom property
  • Media query variables: largely replaced by container
    queries, which ask a better question anyway

What CSS has not taken back is the build step itself:
@use and @forward for splitting a stylesheet into
files that share private variables, @mixin and
@include for reusing a block of declarations with arguments, and
loops and conditionals for generating families of utility classes.

The distinction that decides which to use

A Sass variable is resolved once, when the file is compiled, and does not
exist afterwards. A custom property is a real value in the cascade: it inherits,
it can be overridden on a selector, and reading it from script gives the current
value.

Compile time vs cascade

Which variable mechanism a value actually needs

Sass variables disappear during compilation while custom properties stay live in the browser, so each belongs in a different place.

Can this value change after the stylesheet is compiled?
  • Changes for themes, dark mode, or script
    Use a CSS custom propertyRemains live in the browser cascade
    • Inherits down the tree and overrides per selector
    • Readable and updatable from JavaScript
  • Static or inside a media query condition
    Use a Sass variableSubstituted once at build time
    • Does not exist after compilation
    • Works inside @media condition widths where custom properties cannot

Putting theme colours in Sass variables freezes dark mode; putting media query thresholds in custom properties fails altogether.

Interactive Practice Lab

Edit and run this snippet directly in your browser (zero setup)

CSS
.demo {  display: flex;  flex-wrap: wrap;  justify-content: space-between;  gap: 12px;}.box {  flex: 1 1 80px;  text-align: center;  background: #0ea5e9;}

Live Big-O Complexity & Binary Search Race Lab

Compare complexity curves at scale and watch Linear vs Binary Search race live.

So a theme colour that changes for dark mode has to be a custom property,
because a Sass variable was already substituted before the browser saw the file.
A breakpoint width used only inside a media query condition can be a Sass
variable, because custom properties cannot be used there at all. That pair is the
whole rule, and most codebases get it backwards in one direction or the other.

What a mixin still buys

A mixin emits declarations, so @include visually-hidden can
expand to seven properties that have to appear together and are easy to get
wrong. A custom property cannot do that: it holds one value, not a block. That
is the one genuine gap and it is why utility classes and mixins both still
exist.

Block reuse trade-off

Where mixins, classes, and custom properties overlap

Custom properties hold a single value, whereas mixins and classes reuse whole blocks of properties with opposite costs in compiled CSS.

  • Sass @mixin
  • Utility CSS class
  • CSS custom property
Stylesheet reuse
  • Sass @mixinEmits multi-property blocks that vary by argument, but copies declarations at every call site
  • Utility CSS classEmits multi-property blocks once with zero duplication, but cannot vary by argument
  • CSS custom propertyHolds one live, inheritable value in the browser, but cannot expand into a declaration block

Use a mixin when the emitted block changes with an argument, and a plain CSS class when every call emits the same rules.

The cost is that every include duplicates the declarations at every call
site, which a class does not. A mixin used forty times is forty copies in the
output, so the rule is a mixin when the block varies by argument and a class when
it does not.

What to run in 2026

Dart Sass is the implementation, free and open source, and it is the only one
maintained: node-sass was deprecated and the older @import rule is
deprecated within Sass itself in favour of @use. A project still on
either is on a path that ends, which is worth knowing before adding to it.

Six features, four crossings

What moved from the build step into the browser

Each plank is a feature that used to require a compiler and no longer does, and the two banks are what is left on each side.

Sass, in 2014Six reasons to add a build step to a stylesheet
  1. 01VariablesCustom properties, and they do more: live, inheritable, scriptable
  2. 02NestingNative, with the same & for the parent
  3. 03Colour manipulationcolor-mix and relative colour, at runtime
  4. 04Breakpoint reuseContainer queries, asking about the component instead
Plain CSS, in 2026Two of the six still need the compiler

Two planks are missing on purpose. Mixins with arguments and splitting a stylesheet across files with private variables have no native equivalent, and they are the only honest reasons left to install a compiler.

Native custom properties and nesting are the second, free with the platform
and supported across browsers as of 2026. They replaced the two features Sass was
most often installed for, which means a new project should start with plain CSS
and add Sass when it actually needs a mixin or a file split, rather than
starting with the build step.

Where this stalls people

The stall is a stylesheet where both kinds of variable are in use and nobody
can say which is which. $brand and var(--brand) sit in
the same file, one of them changes with the theme and one does not, and the bug
is a colour that is correct everywhere except in dark mode.

Naming collision bug

How mixing Sass and CSS variables breaks dark mode

When $brand and var(--brand) share a file and a name, the stylesheet hides which colours respond to theme changes and which stay frozen.

Never give a Sass variable and a CSS custom property the same name: runtime values belong in custom properties, source shortcuts in Sass.

The convention that ends it costs nothing: anything that can change while the
page is open is a custom property, and anything that only exists to make the
source shorter is a Sass variable, and the two are never given the same name.
What those values are styling is
margin, border, padding, and
where widths go wrong
, the queries they feed are
one document, every screen,
and the build that runs the compiler is
splitting code up, and
putting it back together
, inside
how a page is laid out and how it looks.

Alongside this

Above this