list.separator() belongs to the built-in sass:list module. It reports how list items are separated. This page covers space, comma, and slash, defaults for singles and empty lists, pairing with list.join / list.slash, Dart Sass support, and five compiled examples.
01
Concept
Read the separator
02
Module
@use "sass:list"
03
Values
space / comma / slash
04
Default
Missing → space
05
Pair with
join / slash
06
Practice
5 examples
Concept
What Is list.separator()?
Sass lists can be space-separated (1px solid red), comma-separated ((Helvetica, Arial), or slash-separated (1px / 50px / 100px). list.separator returns which kind you have—as an unquoted string name.
list.separator(1px 2px 3px) → space
list.separator((1px, 2px, 3px)) → comma
list.separator("Helvetica") → space (no separator → space)
list.separator(()) → space
💡
Beginner tip
Separators and brackets are different. Use list.is-bracketed() for […], and list.separator for how items are joined.
Foundation
📝 Syntax
Load the list module, then call the function:
styles.scss
@use "sass:list";
list.separator($list)
Parameters
Parameter
Type
Required
Description
$list
List (or map / single value)
Yes
The list whose separator you want to inspect.
Return value
Type
Result
Unquoted string
space, comma, or slash
Default
If the list has no separator, returns space
Modules
📦 Loading sass:list
styles.scss
// Recommended — namespaced
@use "sass:list";
$sep: list.separator(1px 2px 3px);
// Optional — bring members into scope
@use "sass:list" as *;
$sep: separator(1px 2px 3px);
// Optional — custom namespace
@use "sass:list" as l;
$sep: l.separator(1px 2px 3px);
// Legacy global (no @use module API)
// $sep: list-separator(1px 2px 3px);
⚠️
Put @use first
Keep @use "sass:list"; near the top of the file, before most other rules. The old global name is list-separator(), not separator() alone.
Details
🔍 Slash Separators with list.slash
Slash-separated lists are common for ratios and some CSS shorthands. Build them with list.slash, then inspect with list.separator.
list.slash(16, 9) builds a slash list that CSS aspect-ratio can use, and list.separator reports slash for debugging or mixin guards.
Applications
🚀 Real-World Use Cases
Mixin APIs — branch when a caller passes comma vs space lists.
Debugging joins — verify $separator after list.join.
Font stacks — confirm comma separation before emitting font-family.
Ratios / tracks — assert slash lists from list.slash.
Border / margin tokens — document that design tokens are space lists.
🧠 How Compilation Works
1
Write SCSS
Call list.separator($list) after @use "sass:list".
Source
2
Read structure
Dart Sass looks up the list’s stored separator (or defaults to space).
Compile
3
Return a name
You get space, comma, or slash for @if or custom properties.
Result
4
✓
CSS sees values
No Sass call remains—only the finished CSS you emitted.
Watch Out
⚠️ Common Pitfalls
Calling global separator() — the legacy name is list-separator().
Expecting null for singles — singles and empty lists return space.
Mixing up brackets — use list.is-bracketed for […].
Comma args in mixins — wrap comma lists in parentheses when passing arguments.
Forgetting @use — list.separator needs sass:list.
Pro Tips
💡 Best Practices
✅ Do
Use @use "sass:list" and list.separator() in new SCSS
Pair with list.join(..., $separator: …) when creating lists
Use list.slash when you need slash-separated values
Compare against space, comma, or slash in @if
Prefer Dart Sass for built-in modules
❌ Don’t
Expect the browser to evaluate list.separator
Assume singles return a special “none” value
Confuse this helper with CSS string separators
Rely on LibSass for @use "sass:list"
Pass bare comma lists as mixin arguments without parentheses
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about list.separator()
Read space / comma / slash—defaults to space when none is stored.
5
Core concepts
📝01
Call
list.separator($list)
API
📦02
Module
sass:list
@use
🔢03
Returns
space|comma|slash
Rule
❓04
Default
space if none
Safe
✓05
Prefer
Dart Sass 1.23+
Tooling
❓ Frequently Asked Questions
list.separator($list) returns the separator name used by $list: space, comma, or slash. Example: list.separator(1px 2px 3px) is space; list.separator((1px, 2px, 3px)) is comma.
Official docs: if $list doesn’t have a separator, the function returns space. That covers single values and empty lists.
Build a slash-separated list with list.slash(...), then list.separator will report slash. Example: list.separator(list.slash(1px, 50px, 100px)) is slash.
The modern module API is list.separator(). The legacy global function is list-separator($list)—not separator() alone.
No. Brackets and separators are independent. list.is-bracketed checks […]; list.separator checks space/comma/slash.
Built-in modules with @use need Dart Sass 1.23+. LibSass and Ruby Sass do not load sass:list the same way—use list-separator() there if you must.
Did you know?
Slash lists used to be awkward because / meant division in Sass. That is why list.slash() exists as a helper until slash list literals are fully settled in everyday syntax.
list.separator() returns whether a Sass list uses space, comma, or slash separators. Load it through sass:list, remember the default is space, and pair it with list.join / list.slash when you build lists.