map.values() belongs to the built-in sass:map module. It returns a comma-separated list of every value in a map. This page covers order, nested map values, vs map.keys, the legacy map-values name, looping patterns, and five compiled examples.
01
Concept
List all values
02
Module
@use "sass:map"
03
Result
Comma-separated list
04
vs keys
Values vs names
05
Loops
@each patterns
06
Practice
5 examples
Concept
What Is map.values()?
Maps store named pairs like "medium": 500. Sometimes you only need the data—the numbers, colors, or lengths—not the names. Official docs: map.values returns a comma-separated list of all values in $map.
Order matches the map’s key order
Only top-level values of the map you pass (nested maps appear as whole items)
Result is a list—use list.length, list.nth, or @each
💡
Beginner tip
Think of a table of contents: map.keys lists the chapter titles. map.values lists the page numbers. map.get opens one chapter.
Foundation
📝 Syntax
Load the map module, then call the function:
styles.scss
@use "sass:map";
map.values($map)
// Legacy global name (still works)
map-values($map)
Parameters
Parameter
Type
Required
Description
$map
Map
Yes
Map whose values you want. Not modified.
Return value
Type
Result
List
Comma-separated list of all values, in map order (empty list for an empty map)
Modules
📦 Loading sass:map
Modern Sass groups map helpers into a module. Load it with @use, then call map.values. The older global name map-values still works.
styles.scss
// Recommended — namespaced
@use "sass:map";
$nums: map.values($theme);
// Optional — bring members into scope
@use "sass:map" as *;
$nums: values($theme);
// Optional — custom namespace
@use "sass:map" as m;
$nums: m.values($theme);
// Legacy global
$nums: map-values($theme);
⚠️
Put @use first
@use rules must appear before most other rules. Keep @use "sass:map"; near the top of the file.
Details
🔢 Order & Nested Values
Two rules beginners should remember:
Order — values follow the same order as keys in the map
Nesting — if a value is itself a map, that whole map is one list item (no automatic flatten)
styles.scss
@use "sass:map";
$flat: ("regular": 400, "medium": 500, "bold": 700);
map.values($flat);
// 400, 500, 700
$nested: ("weights": ("regular": 400), "family": "Helvetica");
map.values($nested);
// ("regular": 400), "Helvetica" — first item is still a map
Compare
📋 map.values vs map.keys
map.values
map.keys
Returns
Stored values
Key names
Order
Same as map key order
Same as map key order
Best for
Emit numbers/colors; math over tokens
Class names; lookups with map.get
Legacy global
map-values
map-keys
💡
Need both key and value?
Prefer @each $key, $value in $map { ... }. That walks the map directly without calling map.keys or map.values.
Support
🛠 Compatibility
This is about Sass compilers, not browsers. Compiled CSS only contains the finished values you emit from the list (for example colors or lengths).
Implementation
@use "sass:map"
Global map-values
Dart Sass (1.23+)
Yes — preferred
Yes
LibSass
No built-in modules
Yes (legacy)
Ruby Sass
No built-in modules
Yes (legacy)
Prefer Dart Sass for new work and the module API.
Cheat Sheet
⚡ Quick Reference
Goal
Code
Import map
@use "sass:map";
List values
map.values($map)
List keys
map.keys($map)
Count entries
list.length(map.values($map))
Loop values only
@each $v in map.values($map) { ... }
Nested map’s values
map.values(map.get($map, "colors"))
Legacy global call
map-values($map)
Hands-On
Examples Gallery
Each example uses @use "sass:map". Open View Compiled CSS to see what Dart Sass emits.
📚 Getting Started
Official docs sample and looping over values.
Example 1 — List Font Weights (Official Docs)
Turn a weight map into a comma-separated list of numbers.
Three values means three top-level entries. list.length(map.keys($tokens)) would return the same count.
Applications
🚀 Real-World Use Cases
Token dumps — emit every spacing or color value without building class names from keys.
Indexed utilities — generate .pad-1, .pad-2 style classes from value order.
List math — pass map values into list helpers when only magnitudes matter.
Nested branch export — map.values(map.get(...)) for one config subtree.
Quick counts — measure how many top-level tokens a map holds.
🧠 How Compilation Works
1
Write SCSS
Call map.values($map) after @use "sass:map".
Source
2
Collect values
Dart Sass walks the map in key order and builds a list of values.
Compile
3
List returned
Loop with @each, index with list.nth, or count with list.length.
Result
4
✓
CSS sees values
Browsers never see map.values—only the finished CSS you emit.
Watch Out
⚠️ Common Pitfalls
Expecting deep flatten — nested maps stay as map items in the list until you dig in with map.get.
Losing key names — values alone cannot rebuild which token was which; keep keys when names matter.
Order assumptions — order matches the map, but maps built from merges may append new keys at the end.
Forgetting @use — map.values needs sass:map (or use legacy map-values).
Using values when you need pairs — prefer @each $key, $value in $map for named output.
Pro Tips
💡 Best Practices
✅ Do
Use @use "sass:map" and map.values() in new SCSS
Use values when only the data matters (not the names)
Call map.values(map.get(...)) for a nested branch
Pair with list.length / list.nth as needed
Prefer Dart Sass for the module API
❌ Don’t
Expect the browser to evaluate map.values
Assume nested maps are flattened automatically
Drop keys when you still need them for class names
Rely on LibSass for @use "sass:map"
Skip @each $key, $value when both sides are required
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about map.values()
Comma-separated value list—same order as keys; top-level only.
5
Core concepts
📝01
Call
map.values($map)
API
📦02
Module
sass:map
@use
🔢03
Returns
comma-separated list
Rule
❓04
vs keys
data vs names
Safe
✓05
Legacy
map-values still works
Tooling
❓ Frequently Asked Questions
map.values($map) returns a comma-separated list of all values in the map, in the same order as the map’s keys. It does not flatten nested maps—nested map values appear as map items in the list.
map.keys returns the names (keys). map.values returns the stored values in the same order. Use keys when you need names; use values when you only need the numbers, colors, or other data.
Yes. map-values($map) is the older global name. Prefer map.values after @use "sass:map".
No automatic deep flatten. map.values only lists values of the map you pass. To list values inside a nested map, first get that nested map: map.values(map.get($theme, "colors")).
map.values(()) returns an empty list (). list.length of that list is 0.
Use @each $value in map.values($map) { ... }. If you also need the key name, prefer @each $key, $value in $map or loop map.keys and call map.get.
Did you know?
Official Sass docs place map.values next to map.keys as a matching pair: one lists names, the other lists stored data—both as comma-separated lists in the same map order.
map.values() turns a Sass map into a list of its stored data—ideal for loops, indexed utilities, and list helpers when names do not matter. Load it through sass:map, dig into nested branches with map.get first when needed, and pair it with map.keys when you need both sides of each token.