Sass list.separator() Function

Beginner
⏱️ 10 min read
📚 Updated: Jul 2026
🎯 5 Examples
sass:list · Dart Sass 1.23+

What You’ll Learn

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

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.

📝 Syntax

Load the list module, then call the function:

styles.scss
@use "sass:list";

list.separator($list)

Parameters

ParameterTypeRequiredDescription
$listList (or map / single value)YesThe list whose separator you want to inspect.

Return value

TypeResult
Unquoted stringspace, comma, or slash
DefaultIf the list has no separator, returns space

📦 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.

🔍 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.

styles.scss
@use "sass:list";

$tracks: list.slash(1px, 50px, 100px);
// → 1px / 50px / 100px

list.separator($tracks); // slash

📋 list.separator vs list.is-bracketed

list.separatorlist.is-bracketed
QuestionSpace, comma, or slash?Does it use […]?
Outputspace / comma / slashtrue / false
Independent?Yes—e.g. [a, b, c] is bracketed and comma-separated
Set vialist.join(..., $separator: …)list.join(..., $bracketed: …)

🛠 Compatibility

This is about Sass compilers, not browsers. Compiled CSS only contains the finished list values you choose to emit.

Implementation@use "sass:list"Global list-separator()
Dart Sass (1.23+)Yes — preferredYes
LibSassNo built-in modulesYes (legacy)
Ruby SassNo built-in modulesYes (legacy)

⚡ Quick Reference

GoalCode
Import list@use "sass:list";
Space listlist.separator(1px 2px 3px)space
Comma listlist.separator((1px, 2px, 3px))comma
Slash listlist.separator(list.slash(1px, 50px))slash
Single / emptyReturns space
Force separatorlist.join($a, $b, $separator: comma)
Legacy globallist-separator($list)

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 space, comma, singles, and empty lists.

Example 1 — Space, Comma, Single, Empty, Slash (Official Docs + Slash)

Inspect common list shapes, including a slash list from list.slash.

styles.scss
@use "sass:list";
@use "sass:meta";

@debug list.separator(1px 2px 3px);       // space
@debug list.separator((1px, 2px, 3px));   // comma
@debug list.separator("Helvetica");       // space
@debug list.separator(());                // space

$slash: list.slash(1px, 50px, 100px);

.sep {
  --space: #{meta.inspect(list.separator(1px 2px 3px))};
  --comma: #{meta.inspect(list.separator((1px, 2px, 3px)))};
  --single: #{meta.inspect(list.separator("Helvetica"))};
  --empty: #{meta.inspect(list.separator(()))};
  --slash: #{meta.inspect(list.separator($slash))};
}

How It Works

Official docs cover space, comma, and the “no separator → space” rule. Slash lists come from list.slash and report slash.

Example 2 — Separators from list.join and Bracketed Lists

Force a separator with join, and see that brackets do not erase comma style.

styles.scss
@use "sass:list";
@use "sass:meta";

$joined-space: list.join(10px 20px, 30px, $separator: space);
$joined-comma: list.join(10px, 20px, $separator: comma);
$brack: [a, b, c];

.join {
  --js: #{meta.inspect(list.separator($joined-space))};
  --jc: #{meta.inspect(list.separator($joined-comma))};
  --br: #{meta.inspect(list.separator($brack))};
}

How It Works

$separator on list.join() becomes the result’s separator. [a, b, c] is still comma-separated.

📈 Practical Patterns

Mixin branches, borders, and aspect ratios.

Example 3 — Branch in a Mixin by Separator

Expose the separator name and a string snapshot of the list.

styles.scss
@use "sass:list";
@use "sass:meta";

@mixin echo-sep($name, $list) {
  .#{$name} {
    --sep: #{meta.inspect(list.separator($list))};
    content: "#{meta.inspect($list)}";
  }
}

@include echo-sep("plain", 1rem 2rem);
@include echo-sep("fonts", (Helvetica, Arial, sans-serif));
@include echo-sep("ratio", list.slash(16, 9));

How It Works

Wrap comma lists in parentheses when passing them into mixins so Sass does not treat commas as argument separators.

Example 4 — Inspect a Border Shorthand List

Typical CSS border values are space-separated Sass lists.

styles.scss
@use "sass:list";
@use "sass:meta";

$border: 1px solid #336699;

.box {
  --sep: #{meta.inspect(list.separator($border))};
  border: $border;
}

How It Works

Width, style, and color are three space-separated items, so the separator name is space while the border still compiles normally.

Example 5 — Aspect Ratio via Slash List

Confirm a ratio list is slash-separated before emitting CSS.

styles.scss
@use "sass:list";
@use "sass:meta";

$ratio: list.slash(16, 9);

.hero {
  --sep: #{meta.inspect(list.separator($ratio))};
  aspect-ratio: $ratio;
}

How It Works

list.slash(16, 9) builds a slash list that CSS aspect-ratio can use, and list.separator reports slash for debugging or mixin guards.

🚀 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.

⚠️ 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 @uselist.separator needs sass:list.

💡 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

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
📦 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.

Conclusion

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.

Continue with list.nth() or explore list.length().

Next: list.nth()

You learned list.separator()—next, read items by index with list.nth().

list.nth() →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful