A quick start for an opinionated, themeable component library that AI can
compose UIs with. It's built on the generative-UI primitives of
@intentface/ui.
- A closed catalog of 48 components (statements, metrics, tables, charts, timelines, drafts, comparisons…) that a model places with one tool call. Props are closed enums, never colours or classes, so whatever the model composes draws in your theme.
- Themed widgets (cards, tabs, buttons, sliders, selects…) the catalog is built on, usable directly in your app.
- A token theme system: a small
ThemeDefinitioncompiles to--td-*CSS variables, in light and dark. Every widget reads only those. - A playground: components on the left, theme editor on the right. Every change shows in the next frame. The editor is built from the library's own widgets and wears the theme you edit, so it is a preview too.
pnpm install
pnpm devOpen http://localhost:5173. Requires Node 20.19+ and pnpm 10.
| Left: preview | Right: theme editor |
|---|---|
| Introduction: the front page: what the library is and its four ideas (streaming, Markdown, JSON to UI, theme tokens), each shown at work in a loop | |
| Generative UI › Components: every catalog component with its example, three replays (being written, waiting for its data, its content arriving), its props, its JSON, and how it reads as Markdown; then the read-only widgets outside the catalog | Start from: a menu of six complete themes after Intentface, Apple, Claude, Linear, Stripe and ChatGPT |
| Generative UI › Sample view: a pipeline dashboard and an account brief, composed as a model should answer; Stream it in replays the JSON as a model writes it: each component is drawn as its own skeleton and fills in as it is written | Palette: three seed colours, light and dark side by side, generate every role, with live WCAG contrast checks |
| Generative UI › Compose: write a tree as JSON and see it render, with the issues a model would get back | Typography: two families, a base size and a modular scale |
| Chat UI: the thread, messages, steps and composer at work, with scripted replies that stream text and a view | Shape & depth: corner, depth (flat to lit), density, shadow, motion (how content arrives, still to lively) |
| App UI › Components: the controls a reader acts with (buttons, fields, selects, sliders, switches, choices, a dialog), the menus (menu, combobox, popover), the app's frame (shell, nav, file list, tab strip), its records (filter bar, data grid) and its widgets (an agenda, a card composed into an event) | Colors: every token, light and dark in one field. Component overrides: CSS per component, variant and state |
| App UI › Screens: those composed into screens (a CRM workspace with a sidebar, filters over a data grid and an inbox; filters over a table with a confirmed action; a settings form; a step-by-step flow), each holding its own state | |
| How to use: the tool description and schema a model receives, and how to wire them | |
| Light or dark; fluid, tablet or phone width |
Every section and page has its own URL (/generative-ui/sample-view,
/app-ui/screens, /how-to-use), so any of them can be linked. A static host
must serve index.html for those paths.
Export as theme JSON or plain CSS variables, or copy a share link that carries the whole theme in the URL. Edits save in the browser; ⌘Z undoes.
Why it's fast. The preview never re-renders when the theme changes. The
theme lives in a store outside React. One <style> element holds the tokens
for both modes, and it's rewritten at most once per animation frame. Editor
controls subscribe only to the slice they show, and offscreen components skip
layout and paint. A slider drag holds 60 fps with every chart on screen.
ThemeDefinition ─▶ themeToScopedTokens() ─▶ --td-* variables ─┐
▼
model ─show_ui─▶ { root, elements } ─▶ <GenUiView> ─▶ catalog renderers ─▶ widgets
▲
checkShowUiInput() sends issues back to the model
shared/lib/
view-theme.ts the --td-* token table and all widget CSS
genui/catalog.ts the closed catalog: components, props (zod), bindings
genui/show-ui-tool.ts the tool for a model: description, schema, check
src/
components/view/ themed widgets
components/genui/ one renderer per catalog component, and <GenUiView>
components/chat/ the chat UI: thread, message, steps, composer
components/app/ the app's frame, records and widgets: shell, nav, tab strip, data grid, filter bar, agenda
components/icons/ the icon set (Phosphor, swappable in one file)
lib/theme-tokens.ts theme → --td-* (light and dark)
types/theme.ts ThemeDefinition
playground/ the playground app (not part of the library)
docs/
architecture.md how it's wired, and recipes to extend it
theme-tokens.md the token model
composing-views.md the authoring guide to give a model
Copy shared/, src/components/{view,genui,icons}, src/lib, src/types
and src/hooks into your project, keep the @/ and @shared/ aliases, and
take the motion tokens and generative-UI keyframes from src/index.css. Add
src/components/chat for the chat UI and src/components/app for the app
shell, navigation, tab strip, data grid, filter bar and agenda (the grid needs
@tanstack/react-table). Then draw a model's answer:
import { GenUiView } from '@/components/genui/genui-view'
import { ThemeScope } from '@/components/view'
import theme from './my.theme.json' // exported from the playground
<ThemeScope theme={theme} mode={dark ? 'dark' : 'light'}>
<GenUiView
spec={part.input} // partial while streaming
data={{}}
streaming={part.state === 'input-streaming'}
inheritTheme
/>
</ThemeScope>Or skip ThemeScope: load the exported CSS file, put data-dark="true" on
<html> for dark, and pass inheritTheme.
Give the model the tool (shown with the AI SDK; the How to use page also shows the Anthropic SDK):
import { tool, jsonSchema } from 'ai'
import {
SHOW_UI_TOOL,
checkShowUiInput,
showUiLooseInputSchema,
showUiToolDescription,
} from '@shared/lib/genui/show-ui-tool'
const tools = {
[SHOW_UI_TOOL]: tool({
description: showUiToolDescription(),
inputSchema: jsonSchema(showUiLooseInputSchema),
execute: async (input) => {
const checked = await checkShowUiInput(input)
return checked.ok ? { shown: true } : { error: checked.error }
},
}),
}The description documents the common components inline (~3 kB). For the whole catalog, give the model docs/composing-views.md. It covers every component and its props, plus the layout and wording rules that make answers read well.
Hooks for your app: UploadResolverProvider turns upload:<id> image
references into URLs. onNodeError on GenUiView reports render failures.
setNotifier routes copy-failed messages to your toasts. Details are in
docs/architecture.md.
- Theme it in the playground and export. Starter themes live in
src/playground/lib/presets.ts. - Add a component to the catalog: five steps in docs/architecture.md, each enforced by the type checker or the tests.
- Add a token: one row in
TD_TOKENS(docs/theme-tokens.md).
pnpm dev |
the playground, with hot reload |
pnpm build |
type-check and build to dist/ |
pnpm preview |
serve the build |
pnpm test |
the test suite (catalog, renderers, theme system, docs examples) |
pnpm typecheck |
TypeScript only |
It is a static Vite app. On Vercel, import the repository: the Vite preset
is detected (build pnpm build, output dist), and nothing else needs
setting. Any static host works the same way.
The code is MIT: use it in any project, commercial or not.
- Intent Sans (
public/fonts) is a derivative of TASA Orbiter under the SIL Open Font License 1.1; its licence and notice sit next to the file. - The playground loads other typefaces, such as Inter, from Google Fonts at runtime. Each has its own licence, mostly OFL.
- The starter themes named after Apple, Claude, Linear, Stripe and ChatGPT are approximations built from public design notes. They are not affiliated with or endorsed by those companies, and the names are their owners' trademarks.