Polymorph
A design system built as a decision system. Every design decision (a colour, a spacing
step, a focus ring, how a dialog enters) is made once, in the place that owns it. It is
referenced everywhere it applies, checked automatically, and safe to change.
Application code composes a closed vocabulary of components and binds content to it. It
cannot express a colour, a spacing value or an interaction mechanic, because those decisions
are already owned elsewhere. A redesign is therefore an edit to a few JSON files, not a sweep
across screens. An agent building UI with polymorph chooses from the vocabulary instead of
inventing one.
The vocabulary is one set of members, each specified once in design/. On the web, React, Vue,
Svelte, Solid and Angular draw it, and custom elements (<poly-button>) draw it on a page
written in HTML with no build. Two native renderers draw it: SwiftUI on iOS and Jetpack Compose
on Android. Every renderer reads the same tokens from the same theme engine,
and laws hold each one to the same specs.
import { Button, ListPage } from '@polymorph/react-ui'
export function Inbox({ onNewTicket }: { onNewTicket: () => void }) {
return (
<ListPage
title="Inbox"
actions={<Button icon="add" label="New ticket" onClick={onNewTicket} />}
emptyState={{ title: 'No tickets' }}
>
{/* rows… — no className, no style, no colours: those decisions are already made */}
</ListPage>
)
}
How it fits together
- A theme is a pairing of a system (how the product is built: eight design axes and three
fonts, in
design/systems/*.json) and a palette (its colour seeds, in
design/palettes/*.json). The theme engine turns a pairing into a law-checked set of tokens:
--pm-* CSS custom properties for the web, and Swift, Kotlin and Dart values for the native
packages. Light and dark are derived, not authored twice. Any palette works on any system, and
a product can bring its own.
- The vocabulary is a closed set of members in seven tiers: structure, controls, overlays,
layout, charts, the AI conversation tier and page archetypes. Every member has closed props,
ships all of its states and transitions, and is styled only with tokens.
registry/system-card.md
lists them all.
- Renderers. React's members are written by hand on React Aria and Radix. The Vue, Svelte,
Solid and Angular members are generated by
pnpm shells from one framework-neutral
description per member, on Zag state machines. The elements are generated as custom elements
over the Solid members, in the light DOM, so they add no decision of their own. Every web
renderer shares one CSS recipe per member (@polymorph/recipes). The SwiftUI and Compose members are written by hand against contracts
generated from the registry, which is read from the same specs. The platform map
(design/platforms/) says how each member renders on the web, iOS and Android, and the
framework maps (design/frameworks/) say which members each generated web vocabulary ships.
- Red rules (ESLint and Stylelint rules) stop application code from expressing a design
decision, in React and Solid TSX and in Vue, Svelte and Angular templates alike. They do not
read an HTML page. When a product
needs a one-off, the exception ladder gives it a declared, inventoried way to deviate.
- Laws (tests) check every claim: contrast for every pairing, coherence of every system,
every member's states rendered and axe-clean in every web framework, every spec's behaviour
contract run against every web renderer, every spec matching its code, and every native
member token-only and complete.
- For agents, the registry describes the whole system in one generated file
(
registry/system-card.md), an MCP server exposes it as tools, and screens are written as
validated JSON specs and emitted for any web framework, SwiftUI or Compose. A product can also
draw a spec a model writes while it runs, as it streams in, with no build
(docs/run-time-screens.md).
Start