Skip to main content

Selector capture

Selector capture turns a selector into a value — a first-class piece of data you can store in a variable, pass to a function, or build selectors from — instead of live selector syntax attached to a rule.

Write it with *[ … ] in value position (no $ sigil — it serializes back as *[…]):

$card: *[.card];
$both: *[.card, .panel]; // a selector list is fine

What it's for​

Once a selector is a value you can:

  • Reuse it — store a selector once and reference it in several places.
  • Operate on it — pass it to selector-aware functions (append, nest, unify, replace…) that build new selectors from existing ones.
  • Compute selectors — assemble a selector from parts and apply the result.

The captured value round-trips — *[.card, .panel] serializes back to *[.card, .panel] — and behaves the same wherever a selector value is expected. The concept is identical across syntaxes; only the spelling differs.