Sass @use Rule

Beginner
12 min read
Updated: Nov 2026
5 examples
Compiled CSS

Definition and Usage

The Sass @use rule loads mixins, functions, and variables from other stylesheets — called modules — and combines their CSS. Write @use "url";. Loaded CSS is included exactly once, no matter how many times the module is used.

Members are namespaced by default (last URL segment), so short names like $radius stay safe. Prefer @use over deprecated @import. Re-export many modules from one entrypoint with @forward.

Official pattern.

Per the Sass docs: put @use (and @forward) before other rules. You may declare variables used for configuration before @use.

File-local members.

Loaded members are only visible in the stylesheet that wrote @use. Other files need their own @use (or a shared @forward entry).

Dart Sass only.

@use requires Dart Sass 1.23+. LibSass and Ruby Sass do not support it — they must keep using @import.

Syntax

SCSS
// src/_corners.scss
$radius: 3px;

@mixin rounded {
  border-radius: $radius;
}

// style.scss
@use "src/corners";

.button {
  @include corners.rounded;
  padding: 5px + corners.$radius;
}

Pattern: load a module → access members as namespace.$var, namespace.fn(), or @include namespace.mixin.

Namespaces & Config

Core @use shapes:

FormMeaning
@use "src/corners";Load once; namespace = last URL segment
@use "src/corners" as c;Custom short namespace
@use "src/corners" as *;No namespace (best for your own files)
@use "library" with ($x: …);Configure !default variables on first load
@use "sass:math";Built-in module (math, color, string, …)
$-private: 1px;Private member (leading - / _)

SCSS Examples

Multi-file samples show both the module and the loading file. Open View Compiled CSS for verified output.

Example 1 — Default Namespace

Load a partial and call its mixin plus variable.

SCSS
// src/_corners.scss
$radius: 3px;

@mixin rounded {
  border-radius: $radius;
}

// style.scss
@use "src/corners";

.button {
  @include corners.rounded;
  padding: 5px + corners.$radius;
}

How It Works

  1. Namespace comes from the last URL segment: corners.
  2. Include the mixin as corners.rounded.
  3. Read the variable as corners.$radius.
  4. Padding becomes 5px + 3px → 8px.

Example 2 — Custom Namespace

Shorten a busy module name with as.

SCSS
// src/_corners.scss
$radius: 3px;

@mixin rounded {
  border-radius: $radius;
}

// style.scss
@use "src/corners" as c;

.button {
  @include c.rounded;
  padding: 5px + c.$radius;
}

How It Works

  1. Same module, shorter prefix c.
  2. Useful when two modules share a filename.
  3. Call sites stay short without losing clarity.
  4. CSS result matches the default-namespace example.

Example 3 — as *

Bring members into the current scope without a prefix.

SCSS
// src/_corners.scss
$radius: 3px;

@mixin rounded {
  border-radius: $radius;
}

// style.scss
@use "src/corners" as *;

.button {
  @include rounded;
  padding: 5px + $radius;
}

How It Works

  1. No prefix — members look local.
  2. Best for your own design tokens and helpers.
  3. Risk of collisions with third-party libraries.
  4. Prefer a real namespace for code you do not control.

Example 4 — Configure With with

Override !default theme variables when the module first loads.

SCSS
// _library.scss
$black: #000 !default;
$border-radius: 0.25rem !default;
$box-shadow: 0 0.5rem 1rem rgba($black, 0.15) !default;

code {
  border-radius: $border-radius;
  box-shadow: $box-shadow;
}

// style.scss
@use "library" with (
  $black: #222,
  $border-radius: 0.1rem
);

How It Works

  1. Library variables use !default.
  2. with sets values on the first load only.
  3. Radius becomes 0.1rem.
  4. Shadow uses configured $black (#222).

Example 5 — Combine CSS Modules

Load multiple partials; each stylesheet’s CSS is emitted once.

SCSS
// foundation/_code.scss
code {
  padding: .25em;
  line-height: 0;
}

// foundation/_lists.scss
ul, ol {
  text-align: left;

  & & {
    padding: {
      bottom: 0;
      left: 0;
    }
  }
}

// style.scss
@use "foundation/code";
@use "foundation/lists";

How It Works

  1. Both modules contribute CSS to the output.
  2. Nested & & expands every parent pair.
  3. Loading again elsewhere will not duplicate this CSS.
  4. Partials can omit the leading _ in the URL.

Edge Cases & Pitfalls

Most @use bugs are rule order, late configuration, or expecting @import-style globals.

order

@use must come first

Except for @forward (and variables used to configure modules), put @use before other rules.

with

Configure only on first load

If another file already loaded the module, a later with is ignored. Configure at the entrypoint.

scope

Not global like @import

Members stay in this file. Other sheets need their own @use or a shared @forward API.

libsass

Not in LibSass

Module rules need Dart Sass. Migrate off node-sass before relying on @use.

Sass Support

@use is the heart of the Dart Sass module system. It is not a browser CSS feature — support means your Sass compiler understands it.

ImplementationStatus
Dart SassSupported since 1.23.0 (recommended)
LibSass / node-sassNot supported — use @import
Ruby SassNot supported (end-of-life)
BrowsersN/A — only see compiled CSS

Prefer Dart Sass for new projects. SCSS and indented syntax both support @use.

Key Takeaways

  • Load once: @use namespaces members and includes CSS only once.
  • Access as ns.$var, ns.fn(), @include ns.mixin.
  • Shape the load with as, as *, and with.
  • Prefer @use over deprecated @import for all new work.

One line: @use is how modern Sass loads modules — clear namespaces, CSS once.

Compile Notes

@use never reaches the browser. Conceptual flow:

flow.txt
1. Place @use / @forward at the top of the file
2. Resolve the URL (partials, load paths, built-ins)
3. Apply with (…) config on first load only
4. Expose members under the chosen namespace
5. Emit the module’s CSS once in the compiled output

Frequently Asked Questions

The @use rule loads mixins, functions, and variables from another Sass stylesheet (a module) and combines CSS from multiple stylesheets. Each module’s CSS is included exactly once.
By default, use the last part of the URL as a namespace: @use "src/corners"; then corners.$radius, corners.rounded(), or @include corners.rounded.
It loads a module without a namespace so members are available as $radius or @include rounded. Prefer this only for your own stylesheets to avoid name conflicts.
Define variables with !default in the module, then load with @use "library" with ($black: #222, $border-radius: 0.1rem). Configuration can only be applied the first time a module is loaded.
@use namespaces members, loads CSS once, and keeps members private to the loading file. @import is the older global system. Prefer @use (and @forward) for new code.
Dart Sass since 1.23.0. LibSass and Ruby Sass do not support @use—users of those implementations must use @import instead.

Next: Sass @forward Rule

Build a single library entrypoint that re-exports many modules.

Sass @forward Rule →

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.

8 people found this page helpful