selector.append($selectors...) combines selectors without descendant combinators—no whitespace between them. You get compounds like a.disabled or BEM names like .accordion__copy. Load with @use "sass:selector".
If any argument is a comma list, each complex selector is combined separately: append(".accordion", "__copy, __image") → .accordion__copy, .accordion__image.
No parent selectors.
Placeholders are allowed; & is not. Need nesting or &? Use selector.nest().
Syntax
Syntax
SCSS
@use "sass:selector";
selector.append($selectors...) //=> selector
selector.append("a", ".disabled"); // a.disabled
selector.append(".accordion", "__copy"); // .accordion__copy
selector.append(".accordion", "__copy, __image");
// .accordion__copy, .accordion__image
// Use as a rule selector:
#{selector.append(".btn", ".primary")} { ... }
// Global alias (legacy): selector-append($selectors...)
// Prefer selector.append after @use "sass:selector"
Pattern: pass pieces → get a glued selector → interpolate with #{…} when you need a CSS rule.
Reference
Append vs Nest
Same arguments, different combinators:
Helper
Typical result
Use when
selector.append
.alert.warn (no space)
Same element, BEM suffix, compound class
selector.nest
.alert .warn or .alert:hover with &
Nested stylesheet behavior / parent selectors
Official contrast.
Docs point you to selector.nest() when you want nesting instead of glue.
Lists expand so each complex selector gets the prefix.
No & — use nest for parent selectors and descendants.
Prefer @use "sass:selector" (Dart Sass 1.23+).
One line: to stick selectors onto the same element, use selector.append($selectors...).
Practice
Compile Notes
Practical checklist:
checklist.txt
1. @use "sass:selector"
2. Pass clean selector pieces (no leading spaces)
3. Expect compounds / BEM glue — not descendant spaces
4. Interpolate with #{} for CSS rules
5. Use nest when you need & or nesting
Frequently Asked Questions
selector.append($selectors...) combines selectors without descendant combinators—no whitespace between them. Example: append("a", ".disabled") becomes a.disabled.
append glues pieces together (a.disabled, .block__el). nest combines as if nested in the stylesheet, usually with a descendant space (ul li) unless you use &.
If any argument is a selector list, each complex selector is combined separately. append(".accordion", "__copy, __image") becomes .accordion__copy, .accordion__image.
No. Arguments may contain placeholder selectors, but not parent selectors. Use selector.nest when you need &.
Yes. selector-append($selectors...) is the legacy global name. Prefer selector.append after @use "sass:selector".
Dart Sass 1.23+. LibSass and Ruby Sass do not load sass:selector with @use; they may still offer the legacy global name.