meta.module-variables() belongs to the built-in sass:meta module. It returns every variable in a @used module as a map of names (without $) to values. This page covers the official color-token example, map.get usage, and five compiled examples.
01
Concept
Module variable catalog
02
Module
@use "sass:meta"
03
Returns
Map of values
04
Keys
Names without $
05
Read path
map.get
06
Practice
5 examples
Concept
What Is meta.module-variables()?
Official docs: returns all the variables defined in a module, as a map from variable names (without $) to the values of those variables. Think of it as dumping a module’s token sheet into one map you can inspect, loop, or read with map.get.
$module must be a string matching a @use namespace in the current file.
Map keys omit $—$hopbush becomes "hopbush".
Map values are the actual Sass values (colors, lengths, strings, and so on)—ready for CSS.
Dart Sass 1.23+ only—LibSass and Ruby Sass do not support it.
💡
Beginner tip
Unlike module-functions / module-mixins, you do not need meta.call or meta.apply. The map already holds usable values.
Foundation
📝 Syntax
styles.scss
@use "sass:meta";
// Dart Sass 1.23+ (no legacy global name)
meta.module-variables($module)
Parameters
Parameter
Type
Required
Description
$module
String
Yes
Must match the namespace of a @use rule in the current file.
When $name is present, the theme radius is applied. If it were missing, the @else branch would keep a safe fallback.
Applications
🚀 Real-World Use Cases
Design-token dumps — load a colors or spacing module and read tokens by name.
Theme packs — swap which module you @use, then rebuild styles from its map.
Documentation / debug peeks — print keys or the full map with meta.inspect.
Safe optional tokens — map.has-key before map.get.
Code generation — loop @each $name, $value in … to emit CSS custom properties.
🧠 How Compilation Works
1
@use a variables module
Load variables, theme, or another namespace.
Source
2
Build the variables map
Call meta.module-variables("variables").
Compile
3
Read with map.get
Use keys without $, or loop with @each.
Use
4
✓
CSS ships
Browsers never see the map—only finished colors and lengths.
Watch Out
⚠️ Common Pitfalls
Including $ in keys — look up "hopbush", not "$hopbush".
Wrong namespace string — must match this file’s @use … as name exactly.
Module not loaded here — only @use rules in the current file count.
Confusing with function/mixin maps — these values are ready to use; no meta.call / apply.
Expecting LibSass — this API is Dart Sass only (1.23+).
Pro Tips
💡 Best Practices
✅ Do
Use @use "sass:meta" and meta.module-variables()
Store the map once when reading several tokens
Guard optional names with map.has-key
Remember keys omit $
Run Dart Sass 1.23+
❌ Don’t
Pass a path string that is not a current-file @use namespace
Look up keys with a leading $
Use it to list functions or mixins (use the sibling helpers)
Assume browsers evaluate the lookup
Rely on LibSass / Ruby Sass
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about meta.module-variables()
Get every variable in a @use module as a map, then read values with map.get.
5
Core concepts
📝01
API
module-variables($module)
Call
📦02
Module
sass:meta
@use
📚03
Returns
map of values
Result
🔗04
Keys
names without $
Detail
✓05
Read
map.get($vars, name)
Tooling
❓ Frequently Asked Questions
meta.module-variables($module) returns a map of every variable defined in that @use module—keys are names without $, values are the variable values.
A string matching the namespace of a @use rule in the current file—for example "variables" after @use "variables".
No. Official docs: keys are variable names without $. So $hopbush becomes the key hopbush.
global-variable-exists answers yes/no for one global name. module-variables returns the whole catalog of variables in a module as a map.
Use map.get—for example map.get(meta.module-variables("variables"), "hopbush") returns #c69.
Dart Sass 1.23+. LibSass and Ruby Sass do not. Prefer current Dart Sass.
Did you know?
Official Sass docs use playful color names—hopbush, midnight-blue, and wafer—to show that module-variables returns a plain map of tokens you can treat like any other Sass map.
meta.module-variables() returns a map of every variable in a @used module. Match $module to that namespace, remember keys omit $, and read tokens with map.get on Dart Sass 1.23+.