refract v0.1 · beta
Getting started / Installation

Installation

refract is a small family of packages — a core compiler plus one package per output format. Install the core and just the adapter(s) you need; nothing you don't use lands in your dependency tree (the styled-components peer, for one, only ships with that adapter). The @theme-registry namespace is an intentional home for a family of theming packages — refract is its first member, standalone by design: it depends on none of the others and works entirely on its own.

Terminal
npm install @theme-registry/refract @theme-registry/refract-css
PackageWhat it gives you
@theme-registry/refractCore — createTheme, the format-neutral Model, the refract build CLI, DTCG interop (./dtcg), and the adapter contract (./adapter-kit). Always required.
@theme-registry/refract-csscreateCssAdapter — CSS custom properties + classes. The stable reference adapter.
@theme-registry/refract-scsscreateScssAdapter — Sass $variables + classes.
@theme-registry/refract-jsoncreateJsonAdapter — the full Model as structured JSON.
@theme-registry/refract-styled-componentscreateStyledComponentsAdapter — TS/JS theme modules. Carries the styled-components peer.
@theme-registry/refract-mcpThe Model Context Protocol serverrefract-mcp bin. Serves the project's compiled theme as live agent tools + resources.
theme.ts
import { createTheme } from "@theme-registry/refract";
import { createCssAdapter } from "@theme-registry/refract-css";

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

// theme.css · theme.tokens · theme.classes · theme.resolveToken()
document.head.append(
  Object.assign(document.createElement("style"), { textContent: theme.css })
);
Optional peers. styled-components is needed only for that adapter, and typescript only if your build config is a .ts file (a .mjs or .js config never loads it). Install typescript@5 explicitly — a bare npm i -D typescript now resolves to 7.x, the native port, whose main entry exports only a version string; the compiler API refract transpiles a .ts config with lives behind its ./unstable/* subpaths and isn't stable yet. Scaffolded projects already pin ^5.
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.