Sass list.is-bracketed() Function

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

What You’ll Learn

list.is-bracketed() belongs to the built-in sass:list module. It answers one question: does this list use square brackets? This page covers boolean results, brackets vs parentheses, empty lists, pairing with list.join’s $bracketed flag, Dart Sass support, and five compiled examples.

01

Concept

Detect […]

02

Module

@use "sass:list"

03

Return

true / false

04

Not

Parentheses

05

Pair with

list.join

06

Practice

5 examples

What Is list.is-bracketed()?

In Sass, lists can be written with or without square brackets. Brackets are part of the list’s structure—useful when you want CSS that looks like grid-template-columns: [sidebar] 1fr; or when you intentionally keep a list bracketed inside mixins.

  • list.is-bracketed(1px 2px 3px)false
  • list.is-bracketed([1px, 2px, 3px])true
  • list.is-bracketed((1px, 2px, 3px))false (parentheses ≠ brackets)
💡
Beginner tip

Think of square brackets as a flag on the list, separate from the separator (space, comma, or slash). list.separator tells you the separator; list.is-bracketed tells you about the brackets.

📝 Syntax

Load the list module, then call the function:

styles.scss
@use "sass:list";

list.is-bracketed($list)

Parameters

ParameterTypeRequiredDescription
$listList (or map / single value)YesThe value to inspect. Maps and single values also count as lists in Sass.

Return value

TypeSituationResult
BooleanList has square bracketstrue
BooleanPlain, parenthesized, map, or single valuefalse

📦 Loading sass:list

styles.scss
// Recommended — namespaced
@use "sass:list";
$flag: list.is-bracketed([1px, 2px]);

// Optional — bring members into scope
@use "sass:list" as *;
$flag: is-bracketed([1px, 2px]);

// Optional — custom namespace
@use "sass:list" as l;
$flag: l.is-bracketed([1px, 2px]);
⚠️
Put @use first

Keep @use "sass:list"; near the top of the file, before most other rules.

🔍 Brackets vs Parentheses

Beginners often mix up […] and (…). Only square brackets make list.is-bracketed return true.

styles.scss
@use "sass:list";

// Square brackets → true
$a: list.is-bracketed([10px, 20px]);

// Parentheses / plain lists → false
$b: list.is-bracketed((10px, 20px));
$c: list.is-bracketed(10px 20px);

📋 list.is-bracketed vs list.separator

list.is-bracketedlist.separator
QuestionDoes it use […]?Space, comma, or slash?
Outputtrue / falsespace, comma, or slash
Independent?Yes—a list can be bracketed and comma-separated, for example [a, b, c]
Typical pairInspect structureInspect separator

🛠 Compatibility

This is about Sass compilers, not browsers. Compiled CSS only contains the finished values you choose to emit—never a live is-bracketed call.

Implementation@use "sass:list"Global is-bracketed()
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";
Plain space listlist.is-bracketed(1px 2px 3px)false
Square bracketslist.is-bracketed([1px, 2px, 3px])true
Empty bracketslist.is-bracketed([])true
Force brackets via joinlist.join(10px, 20px, $bracketed: true)
Legacy globalis-bracketed($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 plain vs bracketed lists.

Example 1 — Plain vs Bracketed (Official Docs)

The classic check from the Sass documentation.

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

@debug list.is-bracketed(1px 2px 3px);       // false
@debug list.is-bracketed([1px, 2px, 3px]);   // true

.check {
  --plain: #{meta.inspect(list.is-bracketed(1px 2px 3px))};
  --brack: #{meta.inspect(list.is-bracketed([1px, 2px, 3px]))};
}

How It Works

Space-separated 1px 2px 3px has no brackets. [1px, 2px, 3px] does—so the second call returns true.

Example 2 — Space Lists, Grid Tracks, Singles, and Empty Brackets

Common list shapes you will meet in real SCSS.

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

$space: 1rem 2rem 3rem;
$grid: [auto 1fr minmax(0, 240px)];
$single: 12px;
$empty-brack: [];

.shapes {
  --space: #{meta.inspect(list.is-bracketed($space))};
  --grid: #{meta.inspect(list.is-bracketed($grid))};
  --single: #{meta.inspect(list.is-bracketed($single))};
  --empty: #{meta.inspect(list.is-bracketed($empty-brack))};
}

How It Works

A lone value and a plain space list are not bracketed. A grid-style […] list and even an empty [] both report true.

📈 Practical Patterns

Join flags, mixin branches, and map quirks.

Example 3 — Create or Strip Brackets with list.join

list.join accepts $bracketed. Use list.is-bracketed to verify the result.

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

$tokens: [primary, secondary, muted];
$joined: list.join(10px, 20px, $bracketed: true);
$unbrack: list.join([10px], 20px, $bracketed: false);

.flags {
  --has-brackets: #{meta.inspect(list.is-bracketed($tokens))};
  --joined: #{meta.inspect(list.is-bracketed($joined))};
  --forced-off: #{meta.inspect(list.is-bracketed($unbrack))};
}

How It Works

Starting from a bracketed list, setting $bracketed: false on list.join removes the brackets. Setting $bracketed: true adds them even when the inputs were plain.

Example 4 — Branch in a Mixin

Choose different CSS based on whether the incoming list is bracketed.

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

@mixin emit-list($name, $list) {
  .#{$name} {
    --bracketed: #{meta.inspect(list.is-bracketed($list))};
    @if list.is-bracketed($list) {
      content: "#{meta.inspect($list)}";
    } @else {
      content: "plain-list";
    }
  }
}

@include emit-list("plain", 1px 2px);
@include emit-list("square", [1px, 2px]);

How It Works

The mixin inspects structure at compile time and emits different content values. The browser only sees the finished strings.

Example 5 — Maps and Parentheses Are Not Bracketed

Maps count as lists of pairs, but they do not get square brackets.

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

$map: (a: 1, b: 2);

.meta {
  --map-as-list: #{meta.inspect(list.is-bracketed($map))};
  --parens: #{meta.inspect(list.is-bracketed((1px, 2px, 3px)))};
}

How It Works

Official list helpers work on maps, but is-bracketed still returns false unless the value was written (or built) with […].

🚀 Real-World Use Cases

  • Grid / track lists — detect whether a track list should keep brackets.
  • Design-token helpers — branch mixin output for bracketed vs plain tokens.
  • API validation — assert that a caller passed a bracketed list.
  • Join pipelines — verify $bracketed after list.join.
  • Debugging structure — pair with list.separator in @debug logs.

🧠 How Compilation Works

1

Write SCSS

Call list.is-bracketed($list) after @use "sass:list".

Source
2

Inspect structure

Dart Sass checks whether the list carries square brackets.

Compile
3

Return a boolean

You get true or false for use in @if or custom properties.

Result
4

CSS sees booleans / values

No Sass function remains—only the finished CSS you emitted.

⚠️ Common Pitfalls

  • Parentheses ≠ brackets(a, b) returns false.
  • Confusing with separator — brackets and separators are independent.
  • Expecting CSS to care — browsers never call is-bracketed.
  • Forgetting @uselist.is-bracketed needs sass:list.
  • Assuming maps are bracketed — maps are list-like but not square-bracketed.

💡 Best Practices

✅ Do

  • Use @use "sass:list" and list.is-bracketed() in new SCSS
  • Pair with list.separator when debugging list structure
  • Use list.join(..., $bracketed: …) to set brackets intentionally
  • Treat empty [] as bracketed (true)
  • Prefer Dart Sass for built-in modules

❌ Don’t

  • Expect the browser to evaluate list.is-bracketed
  • Treat parentheses as square brackets
  • Confuse this helper with list.index or membership checks
  • Rely on LibSass for @use "sass:list"
  • Assume a map will report as bracketed

Key Takeaways

Knowledge Unlocked

Five things to remember about list.is-bracketed()

Boolean check for square brackets—not separators, not parentheses.

5
Core concepts
📦 02

Module

sass:list

@use
🔢 03

True when

square […]

Rule
04

False for

() / plain / maps

Safe
05

Prefer

Dart Sass 1.23+

Tooling

❓ Frequently Asked Questions

list.is-bracketed($list) returns true if $list has square brackets, and false otherwise. Example: list.is-bracketed([1px, 2px, 3px]) is true; list.is-bracketed(1px 2px 3px) is false.
No. Round parentheses are grouping/list syntax, not square brackets. list.is-bracketed((1px, 2px, 3px)) returns false.
Yes. [] is a bracketed list, so list.is-bracketed([]) is true.
A lone value like 12px counts as a one-item list without brackets, so list.is-bracketed(12px) is false.
Yes. Global is-bracketed($list) still works. New projects should prefer list.is-bracketed() 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 is-bracketed() name there if you must.
Did you know?

Bracketedness is stored on the list itself. That is why list.join(10px, 20px, $bracketed: true) can invent brackets that were never typed with [ and ] in the source—and why list.is-bracketed can confirm the result afterward.

Conclusion

list.is-bracketed() returns whether a Sass list uses square brackets. Load it through sass:list, remember that parentheses do not count, and pair it with list.join’s $bracketed option when you build lists.

Continue with list.join() or explore list.append().

Next: list.join()

You learned list.is-bracketed()—next, merge lists with list.join().

list.join() →

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