Sass list.separator()

Beginner
10 min read
Updated: Nov 2026
5 examples
Dart Sass 1.23+

Definition and Usage

list.separator($list) returns the name of the separator used by $list as an unquoted string: space, comma, or slash. Load it with @use "sass:list" on Dart Sass 1.23+.

Official docs: if $list has no separator, the result is space (singles and empty lists). Legacy global name: list-separator() — not bare separator().

Official samples.

list.separator(1px 2px 3px) → space. list.separator((1px, 2px, 3px)) → comma. list.separator('Helvetica') → space. list.separator(()) → space.

Brackets are separate.

Use list.is-bracketed() for […]. Separator and brackets are independent flags.

Syntax

SCSS
@use "sass:list";

list.separator(1px 2px 3px);              // space
list.separator((1px, 2px, 3px));          // comma
list.separator('Helvetica');              // space
list.separator(());                       // space
list.separator(list.slash(1px, 50px, 100px)); // slash

// Legacy global name
list-separator(1px 2px 3px);

Pattern: inspect with separator → force a shape with list.join(..., $separator: …) or list.slash().

Separator Values

What you can get back:

ResultTypical input
space1px 2px 3px, singles, empty lists
comma(a, b, c), [a, b, c]
slashlist.slash(1px, 50px, 100px)
Compare with== space / == comma / == slash (unquoted)
No bare separator().

The global built-in is list-separator(). Prefer the module form list.separator() in new SCSS.

SCSS Examples

Examples target Dart Sass 1.23+ with @use "sass:list". Open View Compiled CSS for verified output (matches official Sass docs samples).

Example 1 — Space-Separated List (Official Docs)

A normal spacing list reports space.

SCSS
@use "sass:list";

@debug list.separator(1px 2px 3px); // space

.space {
  --sep: #{list.separator(1px 2px 3px)};
}

How It Works

  1. Values separated by spaces form a space list.
  2. Result is the unquoted string space.
  3. Interpolation writes that name into CSS.
  4. Matches the official Sass docs sample.

Example 2 — Comma-Separated List (Official Docs)

Parentheses with commas report comma.

SCSS
@use "sass:list";

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

.comma {
  --sep: #{list.separator((1px, 2px, 3px))};
}

How It Works

  1. Comma syntax creates a comma-separated list.
  2. Result is comma.
  3. Bracketed comma lists like [1px, 2px] also report comma.
  4. Matches the official Sass docs sample.

Example 3 — Singles and Empty Lists Default to space (Official Docs)

No real separator → Sass still reports space.

SCSS
@use "sass:list";

@debug list.separator('Helvetica'); // space
@debug list.separator(());          // space

.singles {
  --string: #{list.separator('Helvetica')};
  --empty: #{list.separator(())};
}

How It Works

  1. A lone string is a one-item list with no separator.
  2. Empty () also has no separator.
  3. Both report space by official rule.
  4. Do not treat that as proof the list has multiple space-separated items — check length too.

Example 4 — Slash Separator via list.slash

Slash lists are built with a helper, then detected here.

SCSS
@use "sass:list";

@debug list.separator(list.slash(1px, 50px, 100px)); // slash

.slash {
  --sep: #{list.separator(list.slash(1px, 50px, 100px))};
  --forced: #{list.separator(list.join(10px, 20px, $separator: comma))};
}

How It Works

  1. list.slash builds a slash-separated list.
  2. separator reports slash.
  3. join(..., $separator: comma) forces comma.
  4. Useful before emitting font sizes or border-radius slash pairs.

Example 5 — Branch on Separator Before Emitting

Only treat a token as spacing or colors when the separator matches.

SCSS
@use "sass:list";

$spacing: 8px 16px 24px;
$colors: (blue, red, green);

.guard {
  @if list.separator($spacing) == space {
    --spacing-ok: true;
  } @else {
    --spacing-ok: false;
  }

  @if list.separator($colors) == comma {
    --colors-ok: true;
  } @else {
    --colors-ok: false;
  }
}

How It Works

  1. Compare unquoted names with == space / == comma.
  2. Spacing scale is space-separated → ok.
  3. Color list is comma-separated → ok.
  4. Mixins can reject the wrong shape before writing CSS.

Edge Cases & Pitfalls

Most separator bugs are assuming space means multiple items, confusing brackets with separators, or calling separator() as a global.

default

No separator → reports space

Singles and () still return space. Pair with list.length.

brackets

Brackets ≠ separator

[a, b] can be comma + bracketed. Check both helpers when shape matters.

global

Global name is list-separator()

There is no standalone global separator() for lists.

slash

Slash needs list.slash()

Literal / is still awkward in Sass — build slash lists with the helper.

Sass Support

Prefer the module form with Dart Sass 1.23+. Legacy global: list-separator().

APIStatus
list.separator()Dart Sass 1.23+ via @use "sass:list"
Global list-separator()Legacy alias (prefer module form)
Return typeUnquoted string: space / comma / slash
LibSass / Ruby SassNo sass:list module — use list-separator() if needed

Compile with the Dart Sass CLI.

Key Takeaways

  • Returns space, comma, or slash as an unquoted name.
  • No separator defaults to space (singles / empty lists).
  • Force shapes with join $separator or list.slash.
  • Prefer list.separator after @use "sass:list".

One line: when you need to know how a list is separated, call list.separator($list).

Compile Notes

Practical checklist:

checklist.txt
1. @use "sass:list"
2. Compare with == space / == comma / == slash
3. Remember singles/empty default to space
4. Use list.slash() when you need a slash list
5. Check is-bracketed separately from separator

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.

Next: Sass list.nth()

Read the value at a 1-based (or negative) index.

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.

8 people found this page helpful