AI Generate SCSS docs instantly

SCSS Cheat Sheet

Quick reference guide with copy-paste ready code snippets

Try DocuWriter Free

Getting Started

4 snippets

SCSS basics and syntax

Comments

// Single line comment

/* Multi-line
   comment */

Import

@import 'variables';
@import 'mixins';

Nesting

.nav {
  background: blue;
  
  a {
    color: white;
    
    &:hover {
      color: yellow;
    }
  }
}

Parent Selector (&)

.button {
  &:hover { }
  &.active { }
  &--large { }  // BEM
}

Variables

5 snippets

Storing and reusing values

Define Variables

$primary-color: #3498db;
$font-stack: Helvetica, sans-serif;
$base-spacing: 1rem;

Use Variables

.header {
  color: $primary-color;
  font-family: $font-stack;
  padding: $base-spacing;
}

Variable Scope

$global: red;

.block {
  $local: blue;  // Only in .block
  color: $local;
}

Default Values

$color: blue !default;
// Won't override if already set

Interpolation

$name: "primary";

.alert-#{$name} {
  color: red;
}

Mixins

4 snippets

Reusable style blocks with parameters

Define Mixin

@mixin border-radius($radius) {
  -webkit-border-radius: $radius;
  -moz-border-radius: $radius;
  border-radius: $radius;
}

Use Mixin

.button {
  @include border-radius(5px);
}

Default Parameters

@mixin box-shadow($x: 0, $y: 2px, $blur: 4px) {
  box-shadow: $x $y $blur rgba(0,0,0,0.3);
}

Content Block

@mixin respond-to($breakpoint) {
  @media (min-width: $breakpoint) {
    @content;
  }
}

.container {
  @include respond-to(768px) {
    width: 750px;
  }
}

Tired of looking up syntax?

DocuWriter.ai generates documentation and explains code using AI.

Try Free

Functions

4 snippets

Built-in and custom functions

Color Functions

darken($color, 10%);
lighten($color, 10%);
saturate($color, 20%);
desaturate($color, 20%);
alpha($color);

Math Functions

percentage(0.5);  // 50%
round(10.6);      // 11
ceil(10.1);       // 11
floor(10.9);      // 10
abs(-10);         // 10

Custom Function

@function calculate-rem($px) {
  @return $px / 16px * 1rem;
}

.text {
  font-size: calculate-rem(18px);
}

String Functions

quote("hello");        // "hello"
unquote("hello");      // hello
str-length("hello");   // 5
to-upper-case("hi");   // HI

Extend & Placeholder

2 snippets

Sharing styles between selectors

Extend

.error {
  border: 1px red;
  background: #fdd;
}

.serious-error {
  @extend .error;
  border-width: 3px;
}

Placeholder Selector

%button-base {
  padding: 10px;
  border: none;
}

.btn-primary {
  @extend %button-base;
  background: blue;
}

Operators

3 snippets

Math and logic operations

Math Operators

width: 100% / 3;
height: $base-height + 20px;
margin: $spacing * 2;
padding: $value - 10px;

Comparison

@if $width > 1000px {
  width: 100%;
} @else {
  width: 90%;
}

Boolean

@if $theme == "dark" and $high-contrast {
  color: white;
}

Control Flow

4 snippets

If, for, each, and while

If/Else

@if $theme == "dark" {
  background: black;
} @else if $theme == "light" {
  background: white;
} @else {
  background: gray;
}

For Loop

@for $i from 1 through 3 {
  .col-#{$i} {
    width: 100% / $i;
  }
}

Each Loop

@each $color in red, green, blue {
  .#{$color}-text {
    color: $color;
  }
}

Each with Map

$sizes: (small: 12px, medium: 16px, large: 20px);

@each $name, $size in $sizes {
  .text-#{$name} {
    font-size: $size;
  }
}

Maps & Lists

4 snippets

Data structures in SCSS

Define Map

$colors: (
  primary: #3498db,
  secondary: #2ecc71,
  danger: #e74c3c
);

Access Map

color: map-get($colors, primary);

// Or with module system
color: map.get($colors, primary);

Lists

$fonts: Helvetica, Arial, sans-serif;
$sizes: 10px 20px 30px;

List Functions

length($fonts);       // 3
nth($fonts, 1);       // Helvetica
append($fonts, Monaco);

More Cheat Sheets

FAQ

Frequently asked questions

What is a SCSS cheat sheet?

A SCSS cheat sheet is a quick reference guide containing the most commonly used syntax, functions, and patterns in SCSS. It helps developers quickly look up syntax without searching through documentation.

How do I learn SCSS quickly?

Start with the basics: variables, control flow, and functions. Use this cheat sheet as a reference while practicing. For faster learning, try DocuWriter.ai to automatically explain code and generate documentation as you learn.

What are the most important SCSS concepts?

Key SCSS concepts include variables and data types, control flow (if/else, loops), functions, error handling, and working with data structures like arrays and objects/dictionaries.

How can I document my SCSS code?

Use inline comments for complex logic, docstrings for functions and classes, and README files for projects. DocuWriter.ai can automatically generate professional documentation from your SCSS code using AI.

Code Conversion Tools

Convert SCSS to Other Languages

Easily translate your SCSS code to other programming languages with our AI-powered converters

Related resources

Stop memorizing. Start shipping.

Generate SCSS Docs with AI

DocuWriter.ai automatically generates comments, docstrings, and README files for your code.

Auto-generate comments
Create README files
Explain complex code
API documentation
Start Free - No Credit Card

Join 33,700+ developers saving hours every week