Sass At-Rules

Beginner
17 Tutorials
Updated: Nov 2026

What You’ll Learn

At-rules start with @ and tell Sass what to do. Some load code (@use), some define reusable pieces (@mixin, @function), some control flow (@if, @each), and plain CSS at-rules like @media pass through with extra Sass features.

SCSS
@use "sass:math";

@mixin card($pad: 1rem) {
  padding: $pad;
}

.box {
  @include card(2rem);

  @if math.div(1, 2) == 0.5 {
    border-width: 1px;
  }

  @media (min-width: 768px) {
    padding: 3rem;
  }
}

At-Rule Index

Modules & Loading

Load other stylesheets and re-export them.

Reusable Code

Share styles, logic, and selectors.

Messages

Report problems and inspect values.

Selectors & CSS

Escape nesting and use plain CSS at-rules.

Flow Control

Branch and loop at compile time.

Frequently Asked Questions

An at-rule starts with @ and tells Sass what to do, such as @use to load a module, @mixin to define reusable styles, or @if to branch.
Sass-only at-rules like @use, @mixin, @if and @each run at compile time and never appear in the CSS. Plain CSS at-rules such as @media and @keyframes are emitted.
@use. The @import rule is deprecated in favor of the module system (@use and @forward).
Start with @use, @mixin / @include, @function, and @extend, then learn @if and @each.
Open @use first, then the mixin and function tutorials. Pair at-rules with the Values and Functions sections.

Next: Sass @use Rule

Start with the first tutorial in this section.

Continue →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

6 people found this page helpful