refract v0.1 · beta
Core concepts / RawTheme anatomy

RawTheme anatomy

The RawTheme is a plain object — one top-level key per subsystem, nothing else. Every key is optional: emit only the subsystems you author. There is no adapter-specific syntax anywhere in it — the same object drives every adapter.

raw-theme.ts
const raw: RawTheme = {
  colors:     { /* palettes → synthesized tonal steps */ },
  typography: { /* type scale, families, weights, headings */ },
  effects:    { /* shadow, transitions, opacity, blur, z-index */ },
  borders:    { /* width, style, radius, offset + edge recipes */ },
  animation:  { /* durations, easings, keyframes, motion recipes */ },
  layout:     { /* spacing, sizes, columns, grids, stacks, containers */ },
  components: { /* recipes only — compose the subsystems above */ },
  globals:    { preset: "preflight" /* + themed element rules */ },
};

Every subsystem slice shares one shape

Learn the pattern once and it holds across all of them. A slice is an open map of properties, plus a reserved recipes block. A property is either a bare value or an extended property:

KeyShapeMeaning
<property>value | ExtendedPropertyA design value — a token. space: 8 or the extended form below.
basevalueThe property's own value, in extended form.
variantsRecord<name, value>Named siblings of the property (sm/lg, light/dark) — each its own token.
responsive[{ at, … }]Per-breakpoint overrides — lowered to @media / @container var overrides by core.
modesRecord<mode, value>Values swapped by an active mode (e.g. a dark mode scope).
recipesRecipeBlockReserved. Named rule-sets → the classes the adapter emits. Values are token paths, not literals.
refs, not copies. A recipe references a token by path ("colors.brand", "borders.edge.card"); it does not inline the value. That's why override() a base value re-flows everything that referenced it — and why a property reference renders as var(--…), never a frozen literal.

Properties vs. recipes

Two things every subsystem emits, and the split is the whole mental model:

PropertiesRecipes
whatRaw design values — the vocabulary.Named rule-sets that use the vocabulary.
emitsCSS custom properties — --dt-<sub>-<path>.Classes — .dt-<sub>-<group>-<variant>.
valuesLiterals or refs to other properties.Token paths only (refs), never literals.

components is the special case: it declares recipes only — its whole job is to compose properties and recipes from the other subsystems into one class. See Components.

The authored input on this page's subsystem panels is exactly a slice of one real RawTheme — the four presets that drive this site are four such objects. Start with Colors ▸
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.