refract v0.1 · beta
Core concepts / States

States

A recipe's states map compiles to selector rules — :hover, [disabled], focus, and so on. The adapter owns the set of known states; core validates every state: ref against it (so a typo is a build error, not silent CSS).

colors.recipes.ts
solid.brand: {
  background: "brand", color: "brand.text",
  states: [
    { state: "hover",    background: "brand.dark" },
    { state: "disabled", background: "brand.lighter", color: "brand.dark" },
  ],
}

Worked example

emitted
.dt-colors-solid-brand { background: var(--dt-colors-brand); color: var(--dt-colors-brand-text); }
.dt-colors-solid-brand:hover { background: var(--dt-colors-brand-dark); }
.dt-colors-solid-brand[disabled] { background: var(--dt-colors-brand-lighter); color: var(--dt-colors-brand-dark); }

Each state key maps to a selector — hover:hover, disabled[disabled] — on the recipe's own class.

Rules & edge cases

  • The adapter owns the known states. The CSS adapter knows hover, disabled, focus, … ; an inline or JSON adapter may know none. A state the target adapter doesn't declare is a build error — not silent CSS.
  • States ride on the shared class. A component that references a recipe inherits that recipe's :hover etc. for free — see Components.
  • Own delta wins. A component's own state delta and a referenced recipe's state both apply; the delta wins at equal specificity by later source order.
  • Composes with responsive. A responsive entry may carry a state@media { .cls:hover { … } }.
Authored anywhere a recipe is — see Colors / Components. The full known-state set is the adapter's; the messages you'll hit are on the Errors page.

Live — hover & disabled

Technical documentation for @theme-registry/refract · all output is compiled client-side by the real library (CSS adapter). The chrome is theme-aware; the render panes carry each preset's own world. · MIT licensed.