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
Concept
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.
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.
Foundation
📝 Syntax
Load the list module, then call the function:
styles.scss
@use "sass:list";
list.is-bracketed($list)
Parameters
Parameter
Type
Required
Description
$list
List (or map / single value)
Yes
The value to inspect. Maps and single values also count as lists in Sass.
Return value
Type
Situation
Result
Boolean
List has square brackets
true
Boolean
Plain, parenthesized, map, or single value
false
Modules
📦 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.
Details
🔍 Brackets vs Parentheses
Beginners often mix up […] and (…). Only square brackets make list.is-bracketed return true.
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.
Assuming maps are bracketed — maps are list-like but not square-bracketed.
Pro Tips
💡 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
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about list.is-bracketed()
Boolean check for square brackets—not separators, not parentheses.
5
Core concepts
📝01
Call
list.is-bracketed($list)
API
📦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.
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.