refract v0.1 · beta
Adapters / Overview

Adapters — one theme, many formats

You author one RawTheme; it lowers to a format-neutral Model. An adapter refracts that Model into a concrete format. The Model holds no CSS syntax — the adapter owns all naming, units and output — so the same theme can emit CSS, SCSS, JSON tokens, or styled-components, side by side. And the four built-ins aren't a ceiling: an adapter is a standalone package against a stable contract, so you (or the community) can target any format — React Native, Compose, a token pipeline — without touching core.

RawTheme Model adapter CSS · SCSS · JSON · SC
AdapterPackageEmits
CSSrefract-cssA stylesheet — :root vars + recipe classes (theme.css / .classes)CSS →
SCSSrefract-scssSass source — $variables + classes (theme.scss)SCSS →
JSONrefract-jsonrefract's own token document — tokens + rule-sets (theme.json)JSON →
styled-componentsrefract-styled-componentsTS/JS theme modules — a theme object + css recipes + GlobalStyleSC →

The adapter is a required argument to createTheme — core ships no default, which is what keeps the Model format-neutral. All four run in the browser and at build time; every preview on this site is compiled live by the CSS adapter.

The same theme, four formats — live

Below is the current preset — the exact RawTheme behind every panel on this site — refracted through each adapter in your browser. One source object; four outputs. Switch the preset in the top bar and all four re-emit.

Halcyon ·

          
Same RawTheme, no per-format authoring — the Model is format-neutral and each adapter owns its own naming, units and syntax. That's the whole thesis. Compare them side by side, or read each adapter in depth: CSS · SCSS · JSON · styled-components.
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.