meta.keywords() belongs to the built-in sass:meta module. It reads the named arguments from an argument list created with $args... and returns them as a map. This page covers argument lists, keyword maps, the official syntax-colors pattern, and five compiled examples.
01
Concept
Named args → map
02
Module
@use "sass:meta"
03
Input
Argument list
04
Returns
Map of keywords
05
Keys
Names without $
06
Practice
5 examples
Concept
What Is meta.keywords()?
When a mixin or function accepts $args..., callers can pass a mix of positional values and named keywords like $string: #080. Official docs: meta.keywords($args) returns only those keywords as a map from unquoted name strings (without $) to their values.
💡
Beginner tip
Think of $args... as a bag of everything the caller sent. meta.keywords pulls out the labeled sticky notes (named args) and ignores unlabeled items (positional args).
Foundation
📝 Syntax
styles.scss
@use "sass:meta";
// Recommended
meta.keywords($args)
// Legacy global name
keywords($args)
Parameters
Parameter
Type
Required
Description
$args
Argument list
Yes
Must be an argument list—typically from $args... on a mixin or function.
Return value
Type
Result
Map
Keyword names (unquoted strings, no $) → argument values. Empty map if no keywords were passed.
Details
📦 Argument Lists and $args...
You almost always use keywords inside a mixin or function that ends with a rest parameter:
styles.scss
@use "sass:meta";
@mixin demo($args...) {
// $args is an argument list (not a plain list)
$named: meta.keywords($args);
// loop $named with @each ...
}
@include demo($color: teal, $gap: 1rem);
Positional values remain available on the argument list itself.
Keyword entries are collected into the map from meta.keywords.
Map keys never include the $ prefix.
Modules
📦 Loading sass:meta
styles.scss
// Recommended — namespaced
@use "sass:meta";
@mixin m($args...) {
$k: meta.keywords($args);
}
// Optional — bring members into scope
@use "sass:meta" as *;
@mixin m($args...) {
$k: keywords($args);
}
// Legacy global
@mixin m($args...) {
$k: keywords($args);
}
Support
🛠 Compatibility
This is about Sass compilers, not browsers. Keyword extraction runs at compile time.
Implementation
keywords
Dart Sass
Yes — prefer meta.keywords
LibSass
Yes (legacy global / pipelines)
Ruby Sass
Yes (legacy global / pipelines)
Prefer current Dart Sass with @use "sass:meta".
Cheat Sheet
⚡ Quick Reference
Goal
Code
Import meta
@use "sass:meta";
Accept any named args
@mixin name($args...) { … }
Get keyword map
meta.keywords($args)
Loop keywords
@each $name, $value in meta.keywords($args) { … }
Check a key
map.has-key(meta.keywords($args), "debug")
Remember
Keys omit $; positionals are not in the map
Hands-On
Examples Gallery
Each example uses meta.keywords on an argument list. Open View Compiled CSS for verified Dart Sass output.
📚 Getting Started
Official syntax-colors sample and a quick map peek.
Example 1 — Syntax Colors (Official Docs)
Turn named color keywords into generated selectors.
Named args become (name: value, …) with bare keys.
Map
4
✓
You loop and emit CSS
@each turns map entries into selectors or properties.
Watch Out
⚠️ Common Pitfalls
Passing a plain list/map — $args must be an argument list from $args....
Looking for $ in keys — keys are bare names like string, not $string.
Expecting positionals in the map — they stay on the argument list only.
Interpolating unsafe names — keyword keys used as CSS must be valid identifiers/properties.
Confusing with CSS keywords — this is about Sass named arguments, not CSS reserved words.
Pro Tips
💡 Best Practices
✅ Do
Use @use "sass:meta" and meta.keywords()
Pair with $args... on flexible mixins/functions
Loop with @each $name, $value in …
Keep required parameters separate from the rest bag
Validate optional flags with map.has-key
❌ Don’t
Pass ordinary lists into meta.keywords
Assume every caller will pass keywords
Put $ into map key lookups
Emit arbitrary keys as CSS without checks
Expect browsers to evaluate meta.keywords
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about meta.keywords()
Pull named arguments out of an $args... list as a map.
5
Core concepts
📝01
API
keywords($args)
Call
📦02
Module
sass:meta
@use
📚03
Input
argument list
$args...
🔗04
Returns
keyword map
Result
✓05
Keys
no $ prefix
Rule
❓ 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.
Did you know?
Official Sass docs use meta.keywords to power a tiny syntax theme API: pass $string, $comment, and $variable colors, then generate .stx-* rules automatically from the returned map.
meta.keywords() turns named arguments from an $args... argument list into a map you can loop, inspect, or query. Keep required parameters separate, remember keys omit $, and use this pattern for flexible Sass APIs.