Sass list.slash() Function

Beginner
⏱️ 11 min read
📚 Updated: Jul 2026
🎯 5 Examples
sass:list · temporary helper

What You’ll Learn

list.slash() belongs to the built-in sass:list module. It builds a slash-separated list when you cannot type / as a list separator yet. This page covers why it exists, how it differs from math.div(), pairing with list.separator, Dart Sass support, and five compiled examples.

01

Concept

Build a / b lists

02

Module

@use "sass:list"

03

Status

Temporary helper

04

Not division

Use math.div

05

Pair with

list.separator

06

Practice

5 examples

What Is list.slash()?

CSS uses slash separators in places like aspect-ratio: 16 / 9, font: 1.2em / 1.5, and some grid / color syntax. Sass historically treated / as division, so you cannot always write slash lists literally yet. list.slash creates that list structure for you.

  • list.slash(1px, 50px, 100px)1px / 50px / 100px
  • list.slash(16, 9)16 / 9
  • list.separator(list.slash(16, 9))slash
⚠️
Heads up from the docs

Official Sass docs: list.slash() is a temporary solution for creating slash-separated lists. Eventually you will write them literally (for example 1px / 2px / solid). Until slash-as-division is fully retired, use this helper—and use math.div() when you mean real math.

📝 Syntax

Load the list module, then pass one or more values:

styles.scss
@use "sass:list";

list.slash($elements...)

Parameters

ParameterTypeRequiredDescription
$elements...Any (variadic)Yes (one or more)The values to place in the slash-separated list, in order.

Return value

TypeResult
ListA slash-separated list containing $elements

📦 Loading sass:list

styles.scss
// Recommended — namespaced
@use "sass:list";
$ratio: list.slash(16, 9);

// Optional — bring members into scope
@use "sass:list" as *;
$ratio: slash(16, 9);

// Optional — custom namespace
@use "sass:list" as l;
$ratio: l.slash(16, 9);
⚠️
No legacy global slash()

Unlike nth or length, there is no separate global slash() outside the module system. Use list.slash (or @use "sass:list" as *).

🔍 list.slash vs math.div

Both involve the / character in Sass history, but they answer different questions.

list.slashmath.div
PurposeBuild a slash-separated listPerform numeric division
Examplelist.slash(16, 9)16 / 9math.div(16, 9)1.777…
CSS useaspect-ratio, font size/line-heightComputed numbers and units
Modulesass:listsass:math

📋 Creating Slash Lists Other Ways

You can also force a slash separator with list.join() or list.append via $separator: slash.

styles.scss
@use "sass:list";

// Dedicated helper
$list: list.slash(10px, 20px);

// Same separator idea via join
$more: list.join($list, list.slash(30px, 40px), $separator: slash);
// → 10px / 20px / 30px / 40px

🛠 Compatibility

This is about Sass compilers, not browsers. Compiled CSS only contains the finished slash-separated values (for example in aspect-ratio).

Implementationlist.slash()Notes
Dart SassYes — preferredPart of the slash-as-division migration; keep Dart Sass current
LibSassNo modern module APIDoes not load sass:list with @use
Ruby SassNo modern module APILegacy—prefer Dart Sass

⚡ Quick Reference

GoalCode
Import list@use "sass:list";
Slash listlist.slash(1px, 50px, 100px)
Aspect ratioaspect-ratio: list.slash(16, 9);
Check separatorlist.separator($list)slash
Real divisionmath.div($a, $b)
Join as slashlist.join($a, $b, $separator: slash)

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 sample and separator checks.

Example 1 — Create a Slash List (Official Docs)

Build a three-item slash list and confirm the separator name.

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

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

.tracks {
  --tracks: #{meta.inspect(list.slash(1px, 50px, 100px))};
  --sep: #{meta.inspect(list.separator(list.slash(1px, 50px, 100px)))};
}

How It Works

Arguments become list items joined with /. list.separator() reports the unquoted name slash.

Example 2 — Aspect Ratio Token

Emit a CSS aspect-ratio value from a slash list.

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

16 / 9 is a list, not the number ~1.78. That is exactly what aspect-ratio expects.

📈 Practical Patterns

Font shorthand, grid rows, and joining slash lists.

Example 3 — Font Size / Line-Height Pair

Classic CSS font shorthand uses a slash between size and line-height.

styles.scss
@use "sass:list";

$font: list.slash(1.2, 1.6);

.card {
  font: #{$font} system-ui;
}

How It Works

Interpolation keeps the slash list intact inside the font shorthand so the browser sees size and line-height correctly.

Example 4 — Grid Row with span and math.div

Combine slash lists with real division for grid placement (migration-style pattern).

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

$row: list.slash(span math.div(6, 2), 7);

.item {
  grid-row: $row;
}

How It Works

math.div(6, 2) computes 3 for the span count. list.slash then builds the slash-separated grid-row value.

Example 5 — Grow a Slash List with list.join

Keep the slash separator when combining two slash lists.

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

$a: list.slash(10px, 20px);
$b: list.join($a, list.slash(30px, 40px), $separator: slash);

.joined {
  --a: #{meta.inspect($a)};
  --b: #{meta.inspect($b)};
  --len: #{list.length($b)};
}

How It Works

Passing $separator: slash keeps the combined list slash-separated. Length counts items, not slash characters.

🚀 Real-World Use Cases

  • Aspect ratios16 / 9, 4 / 3, and design tokens.
  • Font shorthand — size / line-height pairs in font.
  • Grid placement — slash-separated grid-row / grid-column values.
  • Migration tooling — keep slash lists while moving division to math.div.
  • Design systems — store slash tokens and inspect them with list.separator.

🧠 How Compilation Works

1

Write SCSS

Call list.slash($a, $b, …) after @use "sass:list".

Source
2

Build a slash list

Dart Sass stores the values with a slash separator (not as division).

Compile
3

Emit CSS

Properties receive values like 16 / 9 or span 3 / 7.

Result
4

Browser sees CSS slashes

No Sass function remains—only the finished slash-separated CSS.

⚠️ Common Pitfalls

  • Using slash for math — division belongs in math.div, not list.slash.
  • Expecting a numberlist.slash(16, 9) is a list, not 1.777.
  • Assuming a global slash() — use the sass:list module API.
  • Forgetting it is temporary — plan for literal slash lists as Sass evolves.
  • Forgetting @uselist.slash needs sass:list.

💡 Best Practices

✅ Do

  • Use list.slash() when CSS needs a slash-separated value
  • Use math.div() for numeric division
  • Verify with list.separator(...)slash
  • Prefer current Dart Sass for the slash migration
  • Keep slash tokens in variables for reuse

❌ Don’t

  • Treat list.slash(16, 9) as division math
  • Expect the browser to call list.slash
  • Rely on LibSass for @use "sass:list"
  • Assume a long-term permanent API (docs mark it temporary)
  • Confuse space lists with slash lists when joining

Key Takeaways

Knowledge Unlocked

Five things to remember about list.slash()

Temporary slash-list builder—not division; pair with math.div for math.

5
Core concepts
📦 02

Module

sass:list

@use
🔢 03

Returns

slash-separated list

Rule
04

Status

temporary helper

Docs
05

Division

use math.div()

Tooling

❓ Frequently Asked Questions

list.slash($elements...) returns a slash-separated list containing those elements. Example: list.slash(1px, 50px, 100px) is 1px / 50px / 100px.
Not currently. Official docs describe it as a temporary solution while Sass finishes moving / away from division. It is the supported way to create slash lists today. Later it may become redundant when slash list literals work everywhere.
Use math.div($a, $b) from sass:math. Do not rely on / for division—that path is being phased out in favor of slash as a list separator.
list.separator(list.slash(16, 9)) returns slash.
No. Unlike many other list helpers, slash is provided as list.slash() through the sass:list module (or via @use "sass:list" as *).
Built-in modules with @use need Dart Sass 1.23+. Slash-separated lists and list.slash() arrived as part of the slash-as-division migration—prefer a current Dart Sass release.
Did you know?

The Sass migrator can help move stylesheets from slash-as-division to math.div() and list.slash(). See the official Breaking Change: Slash as Division guide for the full timeline.

Conclusion

list.slash() builds slash-separated Sass lists for CSS values like aspect ratios and font size/line-height pairs. It is a temporary helper during the slash-as-division migration—use math.div() for math, and list.separator to inspect the result.

Continue with list.zip() or explore math.div().

Next: list.zip()

You learned list.slash()—next, pair parallel lists with list.zip().

list.zip() →

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