refract v0.1 · beta
Delivery / Run-time

Run-time

Compile in memory in the app or browser and use the output live — inject theme.css, apply theme.classes, read theme.resolveToken(), and derive child themes with theme.override().

The runtime graph is browser-safe (no Node deps), so createTheme runs client-side. That unlocks live theming, user-editable themes, and per-request themes on the server.

app.ts
import { createTheme } from "@theme-registry/refract";
import { createCssAdapter } from "@theme-registry/refract-css";

const theme = createTheme(raw, { adapter: createCssAdapter() });

// inject once, then use the emitted classes
document.head.append(Object.assign(document.createElement("style"), { textContent: theme.css }));
button.className = theme.classes.components.buttons.primary.className;
override.ts
// derive a CHILD theme — only the delta is re-normalized, parent untouched
const dark = theme.override({
  colors: { brand: { base: "#8aa2ff", text: "#0b1020" } },
});
document.head.append(Object.assign(document.createElement("style"), { textContent: dark.css }));
this page is a run-time example. The showcase compiles four presets in your browser right now; the switcher swaps theme.css, and “Halcyon Noir” is a theme.override() child of Halcyon.
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.