list.join() belongs to the built-in sass:list module. It merges two lists into one flat list. This page covers separators, brackets, when to prefer list.append, Dart Sass support, and five compiled examples.
01
Concept
Merge two lists
02
Module
@use "sass:list"
03
Separator
auto / space / comma
04
Brackets
$bracketed
05
vs append
Flatten vs nest
06
Practice
5 examples
Concept
What Is list.join()?
Think of two stacks of tokens—spacing scales, font families, or color names. You want one list that contains every item from both. list.join builds that combined list at compile time.
list.join(10px 20px, 30px 40px) → 10px 20px 30px 40px
list.join(10px, 20px, $separator: comma) → 10px, 20px
💡
Beginner tip
Official docs warn: because a single value counts as a one-item list, you can join a value onto a list—but if that value is itself a list, join flattens it. Prefer list.append when you mean “add one item.”
Keep @use "sass:list"; near the top of the file, before most other rules.
Details
🔍 list.join vs list.append
This is the most important beginner trap. Both can look like “add more values,” but they treat a list-valued second argument differently.
styles.scss
@use "sass:list";
@use "sass:meta";
// join flattens both sides into one list
$flat: list.join(10px 20px, 30px 40px);
// → 10px 20px 30px 40px
// append nests the second value as a single item
$nested: list.append(10px 20px, 30px 40px);
// → 10px 20px (30px 40px)
list.join
list.append
Best for
Combining two lists
Adding one value
If 2nd arg is a list
Flattens items in
Nests as one item
Official advice
Use for merge
Prefer for “push one”
Compare
📋 Separators and Brackets
$separator and $bracketed are independent. You can force a comma separator, square brackets, or both.
styles.scss
@use "sass:list";
// Force comma separator
list.join(10px, 20px, $separator: comma); // 10px, 20px
// Inherit brackets from $list1
list.join([10px], 20px); // [10px 20px]
// Force brackets on a plain join
list.join(10px, 20px, $bracketed: true); // [10px 20px]
Support
🛠 Compatibility
This is about Sass compilers, not browsers. Compiled CSS only contains the finished list values (for example in margin or font-family).
Implementation
@use "sass:list"
Global join()
Dart Sass (1.23+)
Yes — preferred
Yes
LibSass
No built-in modules
Yes (legacy)
Ruby Sass
No built-in modules
Yes (legacy)
Cheat Sheet
⚡ Quick Reference
Goal
Code
Import list
@use "sass:list";
Merge space lists
list.join(10px 20px, 30px 40px)
Force comma
list.join(10px, 20px, $separator: comma)
Keep / add brackets
list.join([10px], 20px) or $bracketed: true
Add one value
list.append($list, $val) (not join)
Legacy global
join($list1, $list2, …)
Hands-On
Examples Gallery
Each example uses @use "sass:list". Open View Compiled CSS for verified Dart Sass output (official samples where noted).
📚 Getting Started
Official docs samples for merging space and comma lists.
Example 1 — Merge Space and Comma Lists (Official Docs)
Join two lists; separators follow the inputs when $separator is auto.
Starting from a bracketed $list1 keeps brackets. You can also force them on or strip them with $bracketed: true / false. Confirm with list.is-bracketed().
Example 4 — Combine Spacing Scales for Padding
Merge two design-token lists into one CSS shorthand.
Font stacks — combine brand fonts with system fallbacks.
Color or name catalogs — concatenate theme lists for loops.
Bracketed track lists — build grid-related lists with $bracketed.
Mixin APIs — accept two partial lists and join them before emitting CSS.
🧠 How Compilation Works
1
Write SCSS
Call list.join($list1, $list2, …) after @use "sass:list".
Source
2
Merge items
Dart Sass copies every item from both lists into one new list.
Compile
3
Apply options
$separator and $bracketed shape how the result is stored.
Options
4
✓
CSS sees the list
Properties like padding or font-family receive the finished values.
Watch Out
⚠️ Common Pitfalls
Using join instead of append — a list-valued “extra” gets flattened.
Unexpected separator — auto follows $list1 first; force it when unsure.
Forgetting brackets — only $list1 (or $bracketed) controls […].
Forgetting @use — list.join needs sass:list.
Mutating in place — join returns a new list; reassign if you store it.
Pro Tips
💡 Best Practices
✅ Do
Use @use "sass:list" and list.join() in new SCSS
Prefer list.append when adding a single value
Set $separator explicitly when lists may differ
Use $bracketed when CSS structure needs […]
Prefer Dart Sass for built-in modules
❌ Don’t
Expect the browser to evaluate list.join
Use join as a casual “push one item” helper
Assume $list2’s brackets win over $list1
Rely on LibSass for @use "sass:list"
Forget to reassign when updating a stored list variable
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about list.join()
Flatten two lists—control separator and brackets; use append for one item.
5
Core concepts
📝01
Call
list.join($list1, $list2, …)
API
📦02
Module
sass:list
@use
🔢03
Behavior
flattens both
Rule
❓04
Add one
use list.append
Safe
✓05
Prefer
Dart Sass 1.23+
Tooling
❓ Frequently Asked Questions
list.join($list1, $list2) returns a new list with every element of $list1 followed by every element of $list2. Example: list.join(10px 20px, 30px 40px) is 10px 20px 30px 40px.
Official docs recommend list.append() for a single value. If that value is itself a list, join flattens it into the result; append nests it as one item.
Auto uses $list1’s separator if it has one, else $list2’s, else space. You can force comma, space, or slash.
Auto keeps brackets if $list1 is bracketed. Pass true to force […], or a falsey value to remove brackets.
Yes. Global join($list1, $list2, …) still works. New projects should prefer list.join() after @use "sass:list".
Built-in modules with @use need Dart Sass 1.23+. LibSass and Ruby Sass do not load sass:list the same way—use the global join() name there if you must.
Did you know?
Because individual values count as single-element lists, list.join(10px, 20px) is a valid way to build a two-item list from scratch. Still prefer list.append when your second argument might already be a list.
list.join() merges two Sass lists into one flat list. Load it through sass:list, set $separator and $bracketed when you need control, and reach for list.append when you only want to add a single item.