meta.keywords($args) returns a map of the keyword (named) arguments passed to a mixin or function that takes arbitrary arguments. $args must be an argument list. Load it with @use "sass:meta".
Official sample idea.
A syntax-colors($args...) mixin loops meta.keywords($args) to emit pre span.stx-#{$name} rules from named colors like $string: #080.
Map keys omit $.
Official docs: keys are unquoted strings of argument names without$. So $comment: #800 becomes key comment.
Argument list only.
Pass the rest parameter from $args.... A normal list or map is not the same type and will error.
Syntax
Syntax
SCSS
@use "sass:meta";
meta.keywords($args); //=> map
@mixin syntax-colors($args...) {
@each $name, $color in meta.keywords($args) {
pre span.stx-#{$name} {
color: $color;
}
}
}
@include syntax-colors(
$string: #080,
$comment: #800,
$variable: #60b
);
// Global alias (legacy): keywords($args)
// Prefer meta.keywords after @use "sass:meta"
Pattern: capture $args... → meta.keywords($args) → @each over the map (or inspect / map.has-key).
Reference
Keywords vs Positionals
What ends up in the map:
Passed as
In meta.keywords?
Example
Named keyword
Yes — map entry
$string: #080 → string: #080
Positional only
No
peek(1, 2, 3) → empty map ()
Fixed param + keywords
Only the leftover names
box(1rem, $color: teal)
Ordinary list / map
Error
Must be an argument list
Debug the map shape.
Pair with meta.inspect while learning, or @debug meta.keywords($args) in real projects.
Returns a map of named args from an argument list.
Keys omit $; values are whatever was passed.
Positionals stay out of the keywords map.
Great for flexible APIs that accept any named options.
One line: to read named arguments from $args..., use meta.keywords($args).
Practice
Compile Notes
Practical checklist:
checklist.txt
1. @use "sass:meta"
2. Capture with $args...
3. $map: meta.keywords($args)
4. @each $name, $value in $map { … }
5. Look up bare names (no $) with map.has-key
Frequently Asked Questions
meta.keywords($args) returns a map of the keyword (named) arguments passed into a function or mixin that accepts arbitrary arguments via $args....
An argument list—usually the rest parameter from @mixin name($args...) or @function name($args...). Passing a normal list or map is not the same thing.
Official docs: keys are unquoted strings of argument names without the $. So $string: #080 becomes the map key string (the name without $).
No. keywords() only returns named keyword arguments. Positional values stay in the argument list itself.
Yes. keywords($args) is the legacy global name. Prefer meta.keywords after @use "sass:meta".
Flexible APIs that accept any set of named options—theme tokens, syntax highlighters, or property bags—then loop the map with @each.