SASS Cheat Sheet
A searchable, printable Sass / SCSS reference — variables, nesting, @use modules, mixins, functions, control flow and built-in modules. Free.
Variables
10$primary: #1d6f42;
$radius: 4px !default;
$theme: dark !global;
.box { $w: 10px; width: $w; }
$font-stack: 'Inter', sans-serif;
$gap: 8px * 2;
color: $primary;
$sizes: 4px, 8px, 16px;
$config: ('gap': 8px);
$on: true;
Nesting
9.card { .title { color: red; } }
.btn { &:hover { opacity: .8; } }
.btn { &.is-active {} }
.list { & + & { margin-top: 8px; } }
.menu { .dark & { color: #fff; } }
.box { font: { size: 14px; weight: 700; } }
.grid { > .col {} }
@media (min-width: 768px) { .col { width: 50%; } }
.a { color: red; .b & { color: blue; } }
Partials & modules
10_base.scss
@use 'base';
base.$primary;
@use 'base' as b;
@use 'base' as *;
@use 'theme' with ($primary: #000);
@forward 'buttons';
@forward 'buttons' as btn-*;
@forward 'src/list' hide list-reset;
@forward 'config' with ($gap: 4px !default);
Mixins
10@mixin reset { margin: 0; padding: 0; }
@include reset;
@mixin pad($x) { padding: $x; }
@include pad(8px);
@mixin pad($x: 4px) { padding: $x; }
@include pad($x: 12px);
@mixin shadow($a...) { box-shadow: $a; }
@mixin card { border: 1px solid; @content; }
@include card { color: red; }
@mixin on-dark { @content; }
Functions
9@function double($n) { @return $n * 2; }
width: double(8px);
@function pad($x: 4px) { @return $x; }
@function sum($a, $b) { @return $a + $b; }
@function clampn($n) { @if $n < 0 { @return 0; } @return $n; }
@use 'sass:math';
@function half($n) { @return math.div($n, 2); }
@function list-len($l) { @return list.length($l); }
margin: sum(4px, 8px);
Operators & math
10@use 'sass:math';
width: math.div(100%, 3);
width: 100% - 20px;
margin: 4px + 4px;
width: 2 * 8px;
$r: 10 % 3;
@if $a == $b {}
@if $a >= 768px {}
@if $a and $b {}
@if not $disabled {}
Control flow
9@if $on { display: block; }
@else if $alt { display: flex; }
@else { display: none; }
@each $c in red, green, blue {}
@each $name, $val in $map {}
@each $k, $v in ('sm': 4px, 'md': 8px) { .#{$k} { gap: $v; } }
@for $i from 1 through 3 {}
@for $i from 0 to 3 {}
@while $i > 0 { $i: $i - 1; }
Built-in modules
14@use 'sass:math'; math.floor(4.7)
math.ceil(4.1)
math.round(4.5)
math.percentage(math.div(1, 4))
@use 'sass:string'; string.to-upper-case('hi')
string.quote(hello)
@use 'sass:color'; color.adjust($c, $lightness: 10%)
color.scale($c, $lightness: 20%)
color.mix($a, $b, 50%)
@use 'sass:list'; list.length($l)
list.nth($l, 1)
@use 'sass:map'; map.get($m, 'gap')
map.merge($a, $b)
map.keys($m)
Placeholders & inheritance
9%card { border: 1px solid; }
.box { @extend %card; }
.alert { color: red; }
.error { @extend .alert; }
.note { @extend .alert !optional; }
%btn-base { padding: 8px; }
.btn-primary { @extend %btn-base; }
.btn-ghost { @extend %btn-base; }
@include card;
Interpolation & misc
12.icon-#{$name} { content: ''; }
width: calc(100% - #{$gap});
content: '#{$count} items';
--bs-#{$key}: #{$val};
$map: ('sm': 576px, 'md': 768px);
map.get($map, 'md')
@debug $value;
@warn 'deprecated';
@error 'invalid input';
// inline comment
/* block comment */
@import 'base';
No entry matches “:q”.
About SASS Cheat Sheet
This Sass / SCSS cheat sheet covers the preprocessor from syntax to architecture: variables, nesting, partials and modules, mixins, functions, operators and math, control flow, built-in modules, placeholders and inheritance, and interpolation with other miscellany.
It reflects how modern Sass is written — the @use module system and namespaced built-in modules alongside the classic features — so it is equally useful for maintaining an older @import codebase and for writing new module-based stylesheets.
The sheet is free and rendered client-side. Filter every snippet live with the search box, jump to a section from the sticky table of contents, click any snippet to copy it into your stylesheet and print the page for a paper SCSS reference.
How to use SASS Cheat Sheet
- Skim the sections, from Variables and Nesting through Mixins to Built-in modules.
- Search for a feature like mixin, @use or map to filter the sheet live.
- Jump to Control flow or Placeholders & inheritance via the sticky sidebar.
- Click a snippet or its copy icon to copy the SCSS into your stylesheet.
- Print the sheet if you prefer a paper reference while refactoring styles.