SASS-Spickzettel
Eine durchsuchbare, druckbare Sass-/SCSS-Referenz — Variablen, Verschachtelung, @use-Module, Mixins, Funktionen, Kontrollfluss und integrierte Module. Kostenlos.
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';
Kein Eintrag passt zu „:q“.
Über SASS-Spickzettel
Dieser Sass-/SCSS-Spickzettel deckt den Präprozessor von der Syntax bis zur Architektur ab: Variablen, Verschachtelung, Partials und Module, Mixins, Funktionen, Operatoren und Mathematik, Kontrollstrukturen, eingebaute Module, Platzhalter und Vererbung sowie Interpolation mit weiteren Kleinigkeiten.
Er spiegelt, wie modernes Sass heute geschrieben wird — das @use-Modulsystem und namensraumbasierte eingebaute Module neben den klassischen Features —, sodass er gleichermaßen für die Pflege einer älteren @import-Codebasis wie für neue modulbasierte Stylesheets nützlich ist.
Der Spickzettel ist kostenlos und läuft clientseitig. Filtern Sie jedes Snippet live mit dem Suchfeld, springen Sie über das fixierte Inhaltsverzeichnis zu einem Abschnitt, klicken Sie auf ein Snippet, um es in Ihr Stylesheet zu kopieren, und drucken Sie die Seite für eine SCSS-Referenz auf Papier.
So verwenden Sie SASS-Spickzettel
- Überfliegen Sie die Abschnitte, von Variablen und Verschachtelung über Mixins bis Eingebaute Module.
- Suchen Sie nach einem Feature wie mixin, @use oder map, um den Spickzettel live zu filtern.
- Springen Sie über die fixierte Seitenleiste zu Kontrollstrukturen oder Platzhalter & Vererbung.
- Klicken Sie auf ein Snippet oder sein Kopiersymbol, um das SCSS in Ihr Stylesheet zu kopieren.
- Drucken Sie den Spickzettel, wenn Sie beim Refactoring von Styles eine Papierreferenz bevorzugen.