selector.simple-selectors($selector) returns a comma-separated list of the simple selectors inside a compound selector. The simples are unquoted strings. Load with @use "sass:selector".
Official sample idea.
simple-selectors("a.disabled") → a, .disabled; simple-selectors("main.blog:after") → main, .blog, :after.
Compound only.
$selector must be a single compound selector string—no combinators (including spaces) and no commas.
Need commas or spaces?
Use selector.parse() for full selector lists and complex selectors.
Syntax
Syntax
SCSS
@use "sass:selector";
selector.simple-selectors($selector) //=> list
selector.simple-selectors("a.disabled");
// a, .disabled
selector.simple-selectors("main.blog:after");
// main, .blog, :after
// Walk the list:
@each $simple in selector.simple-selectors("a.disabled") { ... }
// Global alias (legacy): simple-selectors($selector)
// Prefer selector.simple-selectors after @use "sass:selector"
Pattern: pass one compound string → get a comma list of simples → walk with sass:list or @each.
vs parse — parse handles full lists and complexes.
Prefer @use "sass:selector" (Dart Sass 1.23+).
One line: to split a compound selector into simples, use selector.simple-selectors($selector).
Practice
Compile Notes
Practical checklist:
checklist.txt
1. @use "sass:selector"
2. Pass one compound string (no spaces / commas)
3. Expect a comma list of unquoted simples
4. Walk with @each or sass:list
5. Use parse for full selector lists
Frequently Asked Questions
selector.simple-selectors($selector) returns a comma-separated list of the simple selectors inside a compound selector. Example: simple-selectors("a.disabled") becomes a, .disabled.
$selector must be a single string that contains a compound selector. It may not contain combinators (including spaces) or commas. So "a.disabled" is OK; "ul li" or "a, button" is not.
The returned list is comma-separated, and the simple selectors are unquoted strings. Example: simple-selectors("main.blog:after") becomes main, .blog, :after.
Yes. simple-selectors($selector) is also available as a legacy global name. Prefer selector.simple-selectors after @use "sass:selector".
parse handles full selector lists with commas and spaces (complex selectors). simple-selectors only splits one compound selector into its simple pieces.
Dart Sass 1.23+. LibSass and Ruby Sass do not load sass:selector with @use; they may still offer the legacy global name.