The Sass @use rule loads other stylesheets as modules. You get their CSS once, plus namespaced variables, functions, and mixins. This page covers namespaces, as *, with configuration, private members, partials, and five compiled examples.
01
Load
@use "url"
02
Namespace
mod.$var
03
Alias
as c / as *
04
Configure
with (…)
05
Privacy
$-private
06
Practice
5 examples
Concept
What Is @use?
Official docs: the @use rule loads mixins, functions, and variables from other Sass stylesheets, and combines CSS from multiple stylesheets together. Stylesheets loaded by @use are called modules. Sass also provides built-in modules like sass:math and sass:string.
CSS from a module is included exactly once, no matter how often it is loaded.
Members are namespaced by default—easy to see where $radius came from.
@use rules must come before other rules (except @forward).
You may declare variables before@use to help configure modules.
Think of @use as borrowing a labeled toolbox: @use "src/corners" gives you corners.rounded, not a pile of global names mixed with everything else.
Foundation
📝 Syntax
styles.scss
@use "url";
@use "url" as alias;
@use "url" as *;
@use "url" with (
$variable: value
);
@use "url" as alias with (
$variable: value
);
Parts of the rule
Part
Meaning
"url"
Module path (extension optional). Use forward slashes.
as alias
Custom namespace instead of the file/folder name
as *
No namespace—members join the current file
with (…)
Override !default variables when the module first loads
API
📦 Loading Members
Official docs: access variables, functions, and mixins with namespace.$var, namespace.fn(), or @include namespace.mixin. By default, the namespace is the last component of the module’s URL.
Members loaded with @use are only visible in the file that loads them.
Other files must write their own @use if they need the same members.
To re-export many modules from one entry file, use @forward.
💡
Fun fact
Because namespaces avoid collisions, you can keep simple names like $radius inside a module—unlike old @import habits that pushed long prefixes such as $mat-corner-radius.
Naming
🏷️ Choosing a Namespace
Write
Access as
@use "src/corners";
corners.$radius
@use "src/corners" as c;
c.$radius
@use "src/corners" as *;
$radius (no prefix)
Official docs: use as * mainly for stylesheets you control. Third-party modules may add members later and cause name conflicts.
Privacy
🔒 Private Members
Official docs: start a name with - or _ to keep it private. Private members work inside the defining file but are not part of the module’s public API.
Official docs: define variables with the !default flag, then load the module with @use "…" with ($name: value). Configured values override the defaults.
A module keeps the same configuration even if loaded again.
@use … with can only be used once per module—the first load.
If you also need a custom namespace: @use "…" as alias with (…) (as before with).
💡
Advanced alternative
Official docs: for flexible themes, prefer a configure mixin plus a styles mixin instead of giant with maps.
Paths
🔍 Finding the Module
Extensions are optional: @use "variables" loads .scss, .sass, or .css.
Use forward slashes in URLs (even on Windows).
URLs are case-sensitive.
Relative paths are checked first; load paths are a fallback.
Partials start with _ (as in _code.scss); omit the underscore when loading.
A folder’s _index.scss loads when you @use "folder".
Compare
🔁 @use vs @import
@use
@import
Namespace
Yes (by default)
No—everything is global
CSS included
Once per module
Can duplicate
Member visibility
Only in the loading file
Shared globally
Modern?
Yes—prefer for new code
Legacy
Support
🛠 Compatibility
This is about Sass compilers, not browsers. @use is resolved at compile time.
Implementation
@use
Dart Sass
Yes (since 1.23.0)
LibSass
No—use @import
Ruby Sass
No—use @import
Cheat Sheet
⚡ Quick Reference
Goal
Code
Load a module
@use "src/corners";
Use a mixin
@include corners.rounded;
Read a variable
corners.$radius
Short alias
@use "src/corners" as c;
No namespace
@use "src/corners" as *;
Configure defaults
@use "library" with ($black: #222);
Built-in module
@use "sass:math";
Private member
$-secret: 1px;
Hands-On
Examples Gallery
Multi-file samples show both the module and the loading file (as in the official docs). Open View Compiled CSS for verified output.
📚 Getting Started
Namespaces, aliases, and built-in-style member access.
Theming — configure !default variables once at the entry file.
Foundation CSS — split reset/base partials and compose them with @use.
🧠 How Compilation Works
1
Write @use at the top
Load modules before other style rules (except @forward).
Source
2
Resolve & configure
Find the file, apply with defaults once, build the namespace.
Compile
3
Use members & CSS
Call mixins/functions; include the module’s CSS a single time.
Emit
4
✓
CSS ships
Browsers only see finished rules like border-radius: 3px.
Watch Out
⚠️ Common Pitfalls
Using @use after CSS rules — it must come first (with @forward / config vars as exceptions).
Forgetting the namespace — write math.abs(), not bare abs(), after @use "sass:math".
Configuring twice — with only works on the first load of a module.
as * collisions — limit star loads to your own files.
Backslashes on Windows — always use / in module URLs.
Pro Tips
💡 Best Practices
✅ Do
Prefer @use (and @forward) over @import
Keep clear namespaces for shared libraries
Use partials (_file.scss) for modules
Configure themes once at the entry stylesheet
Hide internals with $-private names
❌ Don’t
Expect LibSass to support @use
Star-import every third-party library
Put @use in the middle of a stylesheet
Rely on @import for new projects
Expose every helper as a public member
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about Sass @use
Load modules once, with namespaces, on Dart Sass 1.23+.
5
Core concepts
📝01
Rule
@use "url"
Call
🏷️02
Namespace
mod.$var
Access
⚙️03
Config
with (!default)
Theme
🔒04
Private
$-name / _name
API
✓05
Once
CSS included once
Rule
❓ 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. Official docs recommend 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.
Did you know?
Official Sass docs note that members from @use stay local to the loading file—so you can always tell whether $radius came from corners or somewhere else by reading the namespace.
@use is the modern way to compose Sass: load a module once, keep members namespaced, configure !default values when needed, and leave LibSass-era @import behind on Dart Sass 1.23+.