selector.simple-selectors() belongs to the built-in sass:selector module. It splits one compound selector into its simple pieces—tags, classes, IDs, and pseudos. This page covers the compound-only rule, list helpers, and five compiled examples.
01
Concept
Compound → simples
02
Module
@use "sass:selector"
03
Returns
Comma list
04
Args
$selector
05
Limit
No spaces / commas
06
Practice
5 examples
Concept
What Is selector.simple-selectors()?
Official docs: returns a list of simple selectors in $selector. The argument must be a single string that contains a compound selector—no combinators (including spaces) and no commas.
The returned list is comma-separated.
Each simple selector is an unquoted string (a, .disabled, :after).
Use sass:list / @each to walk the parts.
For full selector lists with spaces or commas, use selector.parse() instead.
💡
Beginner tip
A compound selector targets one element with several conditions stuck together: a.disabled means “an a that also has class disabled.” This helper pulls those conditions apart.
Foundation
📝 Syntax
styles.scss
@use "sass:selector";
// Recommended
selector.simple-selectors($selector)
// Legacy global name
simple-selectors($selector)
Parameters
Parameter
Type
Required
Description
$selector
String (compound selector)
Yes
One compound selector—no spaces, no commas, no other combinators.
Return value
Type
Result
List
Comma-separated list of unquoted simple-selector strings
Modules
📦 Loading sass:selector
styles.scss
// Recommended — namespaced (Dart Sass 1.23+)
@use "sass:selector";
$parts: selector.simple-selectors("a.disabled"); // a, .disabled
// Optional — bring members into scope
@use "sass:selector" as *;
$parts: simple-selectors("main.blog:after");
// Legacy global
$parts: simple-selectors("a.disabled");
Details
🎨 Official Patterns
Call
Result
simple-selectors("a.disabled")
a, .disabled
simple-selectors("main.blog:after")
main, .blog, :after
Tags, classes, and pseudo-elements/classes all count as separate simple selectors when they sit in the same compound.
Compare
⚖️ simple-selectors vs parse
Helper
Input
What you get
selector.simple-selectors
One compound (a.disabled)
List of simple pieces
selector.parse
Full selector list (.a .b, .c)
Nested complex/compound lists
Support
🛠 Compatibility
This is about Sass compilers, not browsers. Splitting happens at compile time.
Implementation
simple-selectors
Dart Sass
Yes — prefer selector.simple-selectors (module since 1.23.0)
LibSass
Legacy simple-selectors may exist; no @use "sass:selector"
Ruby Sass
Legacy simple-selectors may exist; no @use "sass:selector"
Prefer current Dart Sass so the module API matches the official docs.
Cheat Sheet
⚡ Quick Reference
Goal
Code
Import selector
@use "sass:selector";
Split a compound
selector.simple-selectors("a.disabled")
Count parts
list.length(selector.simple-selectors($sel))
First / last part
list.nth($parts, 1) / list.nth($parts, -1)
Loop parts
@each $simple in selector.simple-selectors($sel)
Need spaces / commas
selector.parse(…) instead
Hands-On
Examples Gallery
Each example uses selector.simple-selectors at compile time (Dart Sass 1.23+). Open View Compiled CSS for verified output.
Because each simple selector is a string in the list, equality checks are straightforward for mixin/function guards.
Applications
🚀 Real-World Use Cases
Validation — require a type selector or forbid certain pseudos.
Design-system APIs — accept a compound string and branch on its parts.
Debugging — print each simple piece with meta.inspect.
Rebuild helpers — drop or swap one simple selector, then append again.
Teaching CSS — show beginners what lives inside a compound selector.
🧠 How Compilation Works
1
Pass one compound
Call selector.simple-selectors("a.disabled").
Source
2
Sass splits simples
Builds a comma list of unquoted strings.
Compile
3
Inspect or loop
Use list, @each, or rebuild with append.
Use
4
✓
CSS ships
Browsers never see the list—only the CSS you emit from it.
Watch Out
⚠️ Common Pitfalls
Passing descendants — "ul li" has a space; use parse, not simple-selectors.
Passing selector lists — commas are not allowed in the input.
Expecting nested lists — you get a flat comma list of strings.
Confusing with parse — parse handles full selector structure; this helper is compound-only.
Old compilers without modules — use Dart Sass 1.23+ for @use "sass:selector".
Pro Tips
💡 Best Practices
✅ Do
Use @use "sass:selector" and selector.simple-selectors()
Pass clean compound strings only
Pair with sass:list and @each
Use parse when you need spaces or commas
Prefer Dart Sass 1.23+
❌ Don’t
Pass combinators or selector lists
Assume the result is a nested selector-value list like parse
Forget quotes when comparing string pieces in @if
Expect browsers to evaluate the call
Rely on LibSass for the module API
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about selector.simple-selectors()
Split one compound selector into a comma list of simple string pieces.
5
Core concepts
📝01
API
simple-selectors($sel)
Call
📦02
Module
sass:selector
@use
🔗03
Input
compound only
Rule
📚04
Output
comma list
List
✓05
Alt
parse for lists
Compare
❓ 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.
Official docs: $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.
Did you know?
Official Sass docs emphasize that the input must be a compound selector string—so this helper is intentionally narrower than selector.parse, which understands full selector lists.
selector.simple-selectors() splits one compound selector into a comma list of simple string pieces. Keep inputs free of spaces and commas, walk the list with sass:list or @each, and use parse for fuller selector structures.