meta.load-css() belongs to the built-in sass:meta module. It loads another stylesheet module and includes only its CSS where you write the include—even nested under a selector. This page covers $with configuration, vs @use, nesting, dynamic URLs, Dart Sass 1.23+, and five examples.
01
Concept
Include module CSS
02
Module
@use "sass:meta"
03
Config
$with map
04
Nesting
Under selectors
05
vs @use
CSS only
06
Practice
5 examples
Concept
What Is meta.load-css()?
@use is the usual way to load a Sass module: you get its CSS and its members (variables, mixins, functions). Sometimes you only want the CSS, or you want that CSS nested under body.dark or a media query. Official docs: meta.load-css loads the module at $url and includes its CSS as though it were written as the contents of this mixin.
Use it with @include (it is a meta mixin)
Optional $with configures !default variables in the loaded file
Members from the loaded module are not available in the current file
Can appear anywhere—including nested inside style rules
💡
Beginner tip
Think of @use as borrowing a toolbox and hanging the posters on your wall. meta.load-css only hangs the posters—and you can hang them inside a room labeled body.dark.
You cannot provide configuration to a module that has already been loaded—whether or not it was loaded with configuration. Plan $with for the first load.
Support
🛠 Compatibility
This is about Sass compilers, not browsers. The mixin runs at compile time; browsers only see the nested CSS it produces.
Dart Sass evaluates _button.scss and writes its CSS where the include sits. You cannot call mixins from button in style.scss unless you also @use that module.
Example 2 — Configure with $with (Official Docs)
Nest dark-theme code styles under body.dark and flip a !default flag.
Each include nests the same CSS under a different parent. The module still evaluates once overall, but the CSS is emitted at each include site with the surrounding selectors.
Example 4 — URL from a Variable / Interpolation
Official docs: the module URL can come from a variable and include interpolation.
Dynamic theme paths — build the module URL from a variable or interpolation.
Media-scoped sheets — load print or reduced-motion CSS inside the matching query.
CSS-only composition — pull styles without exposing another file’s mixins into your namespace.
🧠 How Compilation Works
1
Write the include
Call @include meta.load-css($url, $with: ...) where the CSS should appear.
Source
2
Load & configure
Dart Sass loads the module (once) and applies $with to !default variables.
Compile
3
Nest if needed
Surrounding selectors or media queries wrap the emitted rules.
Nest
4
✓
Plain CSS ships
Browsers never see meta.load-css—only the finished nested CSS.
Watch Out
⚠️ Common Pitfalls
Expecting members — variables/mixins from the loaded file are not available; use @use when you need them.
CSS url() as $url — pass a module string like "dark-theme/code", not url(...).
Reconfiguring a loaded module — first load wins; later $with cannot reconfigure it.
Forgetting !default — $with configures defaulted variables; non-default variables may not accept overrides the same way.
Using it as a value — always @include; do not assign the mixin call.
Pro Tips
💡 Best Practices
✅ Do
Use @use "sass:meta" and @include meta.load-css()
Pass module URLs as plain strings (like @use)
Use $with for theme flags on !default variables
Nest includes under theme classes or media queries when useful
Prefer Dart Sass 1.23+
❌ Don’t
Expect the browser to evaluate meta.load-css
Pass a CSS url() as $url
Assume you can call mixins from the loaded file afterward
Try to reconfigure a module that already loaded
Rely on LibSass / Ruby Sass for this API
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about meta.load-css()
Include module CSS anywhere—optional $with; no members; Dart Sass 1.23+.
5
Core concepts
📝01
Call
@include meta.load-css($url)
API
📦02
Module
sass:meta
@use
⚙03
Config
$with map
Rule
❓04
vs @use
CSS only · nestable
Safe
✓05
Prefer
Dart Sass 1.23+
Tooling
❓ Frequently Asked Questions
meta.load-css($url, $with: null) loads the module at $url and includes its CSS as if that CSS were written where you include the mixin. It does not import variables, mixins, or functions into the current file.
@use loads a module and makes its members available (once, at the top). meta.load-css only pulls in CSS, can appear anywhere—even nested under a selector—and accepts a configurable $with map. It never exposes members.
An optional map from variable names (without $) to values. Those values configure !default variables in the loaded module, similar to @use "…" with (…).
The module is evaluated only once, like @use. You also cannot provide configuration to a module that was already loaded—configured or not.
It is a mixin from sass:meta. Always use @include meta.load-css(...). It emits CSS; it does not return a value.
Dart Sass 1.23+. LibSass and Ruby Sass do not provide this mixin. Prefer current Dart Sass.
Did you know?
The official dark-theme sample nests meta.load-css under body.dark so every selector from the loaded file becomes something like body.dark code—a clean way to scope a whole partial without rewriting it.
meta.load-css() is the CSS-only, nestable cousin of @use: include another module’s styles anywhere, optionally configure !default variables with $with, and keep its members out of your namespace. Load it through sass:meta on Dart Sass 1.23+.