<!-- Supply UI v1.1.0 -->

# Supply UI

Supply UI is a free design system: tokens, plain CSS classes and React components that your project owns as source files. Its whole look is a few plain choices, the **theme**, set in one place and never component by component, so one change re-themes everything.

See it live, and try the choices: `https://www.supply.family/ui/`

## What it is

| Part | What you get | Why |
|---|---|---|
| Tokens | CSS variables for colour, type, space, corners, shadows, motion | One place decides the whole look |
| A few choices | One brand colour, the greys, the page, corners, size, icon weight | Every colour is worked out from them, so one choice re-themes everything |
| Light and dark | Both in the same file; light by default, dark or "follow the device" by choice | Nothing to write twice |
| Classes | `ui-btn`, `ui-card`, `ui-input`… on plain HTML | Works in any stack, with no JavaScript |
| React components | `<Button>`, `<Dialog>`, `<Select>`… | Same classes underneath. Every control is a part of UI SDK (ui-sdk.dev, Vercel's open library of interface behaviours), so the keyboard, focus and screen readers work, and an AI assistant can use the app |
| Behaviours | UI SDK's building blocks: moving focus, selecting, dragging, opening, and about 50 more | What the kit does not have, you build from them (see Building what the kit does not have) |
| Fonts | Two pairs to pick between: Inter with Reddit Mono (the default), or DM Sans with Courier Prime. The first of each pair is for the interface, the second for numbers and code | All four are open-licensed (OFL): nobody needs to buy a licence |
| Icons | Lucide line icons | Open source (ISC); they follow the theme's colour and line weight |
| Patterns | Painted pictures made from a word, in the theme's colours | A cover, a person or an empty page never needs a stock photo or an uploaded image |

Everything is MIT, ISC or OFL licensed. The files are copied into your project, so there is nothing to buy and nothing that depends on Supply Family being online.

## Install

All files go in one folder, `src/components/ui/` (use `components/ui/` if the project has no `src`).

**With the command (best: it can update the kit later)**

```bash
npx https://www.supply.family/ui/cli.tgz init
```

It puts the kit in `src/components/ui/` (`--dir` for another folder, `--js` for a JavaScript project) and records what it installed in `supply-ui.json`. Later, `npx https://www.supply.family/ui/cli.tgz update` takes a newer kit: files you have not edited are replaced, and an edited file gets the new version beside it (`button.tsx.new`) to merge. `diff` says what you changed and whether a newer kit exists; the changes of each release are in `/ui/CHANGELOG.md`. Every component has a page at `https://www.supply.family/ui/components/` (and as text, `/ui/components/<name>.md`).

Or by hand:

**TypeScript project**

```bash
mkdir -p src/components && curl -fsSL https://www.supply.family/ui/supply-ui.tgz | tar -xz -C src/components
```

**JavaScript project**

```bash
mkdir -p src/components && curl -fsSL https://www.supply.family/ui/supply-ui-js.tgz | tar -xz -C src/components
```

**Project that already uses the shadcn CLI**

```bash
npx shadcn@latest add https://www.supply.family/ui/r/supply-ui.json
```

**Not React** (Astro, SvelteKit, Laravel, Django, plain HTML): download only the stylesheet and use the classes.

```bash
curl -fsSL https://www.supply.family/ui/supply-ui.css -o supply-ui.css
```

Then, for React:

```bash
npm install @ui-sdk/react@0.1.0-beta.16 @ui-sdk/core@0.1.0-beta.16 lucide-react
```

Install exactly these versions. UI SDK is still a beta and the components are written and tested against this one: do not move it to a newer version by yourself, even if npm suggests it. It needs React 19, which a current Next.js already has.

The same install brings UI SDK's own guide for AI coding assistants, matching the installed version: `node_modules/@ui-sdk/core/skills/ui-sdk/SKILL.md`. Read it once before building screens. If you support skills, `npx skills add vercel-labs/ui --skill ui-sdk` installs the same guide as a skill.

### The CSS

All of the kit's CSS sits in one cascade layer, `supply-ui` (after UI SDK's own, `ui-sdk`). CSS you write outside any layer always wins over it, whatever its specificity, so a change of your own never needs `!important`; Tailwind's layers win over it too. Never put your own rules inside `@layer supply-ui`.

`supply-ui.css` is the whole kit in one file. It also comes in parts, one file per component, at `https://www.supply.family/ui/css/` (each in the same layer, so any set of them keeps its order): `css/index.json` lists them in order, the ones every page needs (`always`), and which parts each React file needs (`needs`). Use the parts only where the size of one file matters; load them in the order `index.json` gives.

When a screen needs something the kit does not have, build it from UI SDK (see Building what the kit does not have, below) and style it only with `var(--ui-…)` tokens and the kit's classes, so it follows the theme like everything else. Do not add another component library.

### Wire it up (Next.js)

`src/app/layout.tsx`

```tsx
import { Courier_Prime, DM_Sans, Inter, Reddit_Mono } from 'next/font/google';
import '../components/ui/supply-ui.css';
import { AgentBridge, ThemeStyle, Toaster, themeAttributes } from '../components/ui';

// The look, as a theme code (make one at https://www.supply.family/ui/).
const THEME = 'sui2-bc2eb32-gn-ps-r12-d100-s175-ml';

const inter = Inter({ subsets: ['latin', 'latin-ext'], variable: '--font-inter' });
const mono = Reddit_Mono({ subsets: ['latin', 'latin-ext'], variable: '--font-reddit-mono' });
// The second pair. `preload: false`: a visitor downloads it only when the theme uses it.
const dmSans = DM_Sans({ subsets: ['latin', 'latin-ext'], variable: '--font-dm-sans', preload: false });
const courier = Courier_Prime({ subsets: ['latin', 'latin-ext'], weight: ['400', '700'], variable: '--font-courier-prime', preload: false });

export default function RootLayout({ children }: { children: React.ReactNode }) {
  const theme = THEME;
  return (
    <html lang="en" {...themeAttributes(theme)} className={`${inter.variable} ${mono.variable} ${dmSans.variable} ${courier.variable}`}>
      <head>
        <ThemeStyle theme={theme} />
      </head>
      <body>
        {children}
        <Toaster />
        <AgentBridge />
      </body>
    </html>
  );
}
```

`next/font` downloads the fonts at build time and serves them from your own site: visitors never contact Google.

Load all four fonts, so the font pair can be switched in the theme. Never write a font name in your own CSS: use `var(--ui-font-sans)` and `var(--ui-font-mono)`, which follow the theme.

Other stacks: `npm install @fontsource-variable/inter @fontsource-variable/reddit-mono @fontsource-variable/dm-sans @fontsource/courier-prime` and import each once (for Courier Prime, its `400.css` and `700.css`). The tokens already look for those font names.

Import `supply-ui.css` once, before any other stylesheet. Delete the starter's own global styles (`globals.css`, `page.module.css`): they fight the system.

A new Next.js app prerenders pages (`cacheComponents`), and anything that reads the clock while a page is drawn stops that. `DatePicker` reads today in the browser by itself. A `Calendar` that is open on the page needs `today="YYYY-MM-DD"` from you, or a `<Suspense>` round it. The same goes for anything of yours that reads `searchParams` or the date.

### The page (a site or a public page)

Every page of a site is a `SitePage`: the header, the page and the footer in the page column, with all the room around them settled. The header sits in its own band, with the same room above and below it, so it reads as centred over the page (never a section's gap under it). The page's sections are a section apart, and the footer sits a section below the last one, under a hairline, with a little room below it. The header lines up with the page column at rest, and the solid bar it becomes on scrolling keeps the same line.

```tsx
<SitePage
  header={<SiteHeader brand="Pinewater" items={links} actions={<ButtonLink href="/book">Book a stay</ButtonLink>} />}
  footer={…}
>
  <Cover seed="Pinewater lake">…</Cover>
  <section id="rooms">…</section>
  <section id="reviews">…</section>
</SitePage>
```

Put each section straight inside it: they are spaced for you, so do not wrap them in a `Stack`, and never build this skeleton yourself from `Container` and `Stack gap={12}`, which puts a whole section's gap under the header. How wide the column runs is the theme's `width` (see The theme). A band that runs the whole width of the window from inside it, such as a picture behind the top of a hotel's page, is a `Cover` or a `Bleed`.

A site needs a logo. When the person has none, give `SiteHeader` the plain name (`brand="Pinewater"`) and it draws one: a mark in the brand colour with the name. For a mark that says what the place is, use `<Logo name="Pinewater" mark={<Trees />} href="/" />`. Never leave a bare underlined word as the brand.

## The look

Supply UI has a character of its own. Build with it, not against it:

- **Open first, cards where they mean something.** Most of a page is open: titles, text, facts, pictures and lists sit straight on the soft grey page (`--ui-bg`). A card (`Card`, near-white) is lifted out of it only for one thing a person picks or acts on, or one task (rule 15), and a quieter group inside a card steps back down (`Inset`, `Cell`). Depth comes from these few layers and a hairline, not from drop shadows. Shadows are only for things that float: menus, dialogs, toasts.
- **Round.** Cards have large corners; buttons, fields, chips and badges are pills. Corners nest: a box inside a padded card, dialog, popover or inset follows its curve. Its corner is the outer corner less the room between them (`--ui-radius-inner`, set by each container for what it holds, never less than `--ui-radius-sm`), and the kit's boxes take it by themselves. A box of your own inside a container uses `border-radius: var(--ui-radius-inner)`, never the same curve as its parent. Room inside a container grows with its corner: pad cards with `--ui-pad` and dialogs or large panels with `--ui-pad-lg`, so a line of text at the top or bottom never sits in the curve.
- **Large and light.** Titles are big and medium weight, never bold. The main fact of a card or a section is one very large number (`Figure`); a row of facts on the page is `Stat`s in a `Grid`, and small facts inside a card are `Cells`.
- **One brand colour, used sparingly.** The primary button, the bar that matters, a link. Everything else is black, white and grey.
- **Ink for what is chosen.** A ticked box, a switch that is on, the chosen tab, the selected day are filled with the text colour (black in light, white in dark), never with the brand colour. So they read the same whatever colour the owner picks.
- **Colour for kinds, not for decoration.** Categories and tags are `Chip`s with a `tone` (a hue); the same kind keeps the same tone everywhere.
- **Pictures are painted.** Where a real image is missing, use a `Pattern`. The top of a public page can be a `Cover`: a picture the width of the window, with what is said on a solid panel over it.
- **Icons where they say something.** A row of facts, a list of details, features, contacts and steps each take a Lucide icon that says what the line is about (`Stat icon`, `DescriptionList` items with `icon`, `ui-icon-tile` with `ItemText`). A page of plain text rows is dull and slow to scan. The same thing keeps the same icon everywhere.
- **Lines between facts.** Rows of facts (an address, opening hours, what is in a booking) are a `DescriptionList`, with a hairline between the rows. Never stack them as loose lines of text.
- **Everything moves softly.** Hovers fade, menus and dialogs slide open and closed, the chosen tab slides to its place. This is built in: do not add your own animations to the components, and for anything new use `--ui-dur-fast` (hovers), `--ui-dur` (opening, closing, sliding) and `--ui-ease`. Buttons change colour when pressed; they never change size.

## The rules

Every screen made with Supply UI keeps these.

1. **Tokens only.** Never write a colour, a font size, a radius, a shadow or a duration by hand. Use `var(--ui-…)`. A hex code or `px` font size in your own CSS is a mistake. Every corner comes from a `--ui-radius-…` token, so nothing keeps its own shape when Corners change: a fixed `border-radius: 12px`, `50%` or `999px` on a new element is a mistake. Every change of look on hover, press or state fades with `--ui-dur-fast` and `--ui-ease`.
2. **Use what exists.** Look in the lists below before making anything. A raw `<button>`, `<input>` or `<select>` without a `ui-` class is a mistake.
3. **Lay out with the helpers.** `Stack`, `Row`, `Grid`, `Container`, `AppShell`. Space comes from `gap`, not from margins on children.
4. **One primary button per view.** The main action is `primary`; everything else is `default` or `ghost`. Deleting is `danger` and asks first with `AlertDialog`.
5. **Three colours of state, each with one meaning.** Do not mix them:
   - **Brand** (`--ui-primary` with `--ui-on-primary`) is the main action and emphasis: the one primary button, links, progress, charts, a badge. Not for decoration, and never as a large background.
   - **Ink** (`--ui-ink` with `--ui-on-ink`) is everything chosen or switched on: checkboxes, radios, switches, the chosen tab or toggle, the selected day, the filled part of a slider. Among many rows (a list, a table, the days inside a range) a chosen row takes the quiet fill `--ui-ink-soft` and a tick. Never show a chosen state in the brand colour: a pale brand would make it unreadable.
   - **Grey** is hover (`--ui-surface-2`, `--ui-surface-3`). Keyboard focus is a ring (`--ui-ring`), which the components draw themselves.
6. **Three ways to tell the person something, each for one job.** `Alert`: it belongs to this page and stays on it (a missing key, a failed payment on this order). `toast`: the answer to what they just did, gone in a few seconds ("Saved", "Deleted" with Undo); never for something they must not miss. `Notification`: something that happened while they were elsewhere, kept in the list under the bell until read.
7. **Status colours mean status.** `success`, `warning`, `danger`, `info` only for those meanings. They do not change with the theme.
8. **Mono for anything that lines up.** Amounts, counts, dates, IDs, codes: `ui-mono` (or `ui-num` in a table cell, which also aligns right).
9. **Every list has three more states.** Empty (`Empty`, with the first action inside), loading (`Skeleton`), error (`Alert tone="danger"`).
10. **Works on a phone, and in any narrow box.** Every screen is checked at 320 (the smallest phone), 375 and 768 px wide and nothing on it may be cut off, cut short with "…" where the whole word matters (a name, a price, a choice), squeezed into lines of two words, or scroll the page sideways. Two things at the two ends of a row that no longer fit side by side go one under the other at the same edge, never one line on the left and the next on the right (a zigzag); a `Board` puts the columns that do not fit under the others. The kit does most of it on its own, following the box it is in rather than the window: `AppShell`, `Split` and `Grid` stack; a `Table` whose columns do not fit turns each row into a block (its first cell the title, every other cell a line named by its column), or keeps its columns and scrolls with `scroll` when it is read down its columns (sorting, many figures); `ResizablePanels` stack and their handle becomes a line; `Pagination` shows fewer numbers; `Steps` keep only the current step's name; `Cells` and wrapping buttons (`ui-btn-group--wrap`) share their rows evenly; a `Segmented` option keeps its word; a `ButtonGroup` or `ToggleGroup` never grows wider than its box (the room round each word shrinks on a small phone, and a group still too long scrolls inside itself); a field in a `Toolbar` keeps a usable width and the buttons wrap under it; `Waterfall` names take a second line; dialog buttons share the width. What you add must do the same: let a title wrap rather than giving it `ui-truncate` (keep that for file names and addresses, where the end can be lost), put a note under a title (`ItemText`) rather than beside it, never give a box a fixed width or a `min-height` together with an `aspect-ratio`, and give two things side by side a way to stack. Touch targets keep the default heights. Run the narrow check below at each width; it must return an empty list.

```js
// Paste into the browser console at 320, 375 and 768 px wide. Lists what is cut, squeezed, too narrow to use, or sticks out.
(() => {
  const out = [];
  const W = document.documentElement.clientWidth;
  if (document.documentElement.scrollWidth > W) out.push(['the page scrolls sideways', document.documentElement.scrollWidth + 'px']);
  const where = (e) => (e.className && typeof e.className === 'string' ? '.' + e.className.trim().split(/\s+/).join('.') : e.tagName.toLowerCase()) + ' "' + (e.textContent || e.value || '').trim().slice(0, 30) + '"';
  // Inside a box that scrolls or clips sideways on purpose (a table that scrolls, a carousel, a row of tabs).
  const held = (e) => { for (let p = e.parentElement; p && p !== document.body; p = p.parentElement) if (/auto|scroll|hidden|clip/.test(getComputedStyle(p).overflowX)) return true; return false; };
  for (const e of document.querySelectorAll('body *')) {
    const r = e.getBoundingClientRect(), cs = getComputedStyle(e);
    if (!r.width || !r.height || cs.visibility === 'hidden' || e.closest('[aria-hidden="true"], svg')) continue;
    if ((r.right > W + 1 || r.left < -1) && cs.position !== 'fixed' && !held(e)) out.push(['sticks out of the screen', where(e)]);
    if (cs.textOverflow === 'ellipsis' && cs.display !== 'inline' && e.scrollWidth > e.clientWidth + 1) out.push(['cut short with …', where(e)]);
    const words = [...e.childNodes].filter((n) => n.nodeType === 3).map((n) => n.textContent).join(' ').trim().split(/\s+/).filter(Boolean).length;
    if (words >= 5 && cs.display !== 'inline') {
      // A table cell is as tall as its row, so its own text is measured. Words in code, links and bold are words of the line too.
      const text = document.createRange();
      text.selectNodeContents(e);
      const tall = /^T[DH]$/.test(e.tagName) ? text.getBoundingClientRect().height : e.clientHeight - parseFloat(cs.paddingTop) - parseFloat(cs.paddingBottom);
      const lines = Math.round(tall / (parseFloat(cs.lineHeight) || parseFloat(cs.fontSize) * 1.4));
      const said = [...e.childNodes].filter((n) => n.nodeType === 3 || (n.nodeType === 1 && getComputedStyle(n).display.startsWith('inline'))).map((n) => n.textContent).join(' ').trim().split(/\s+/).filter(Boolean).length;
      if (lines >= 4 && said / lines < 2.6) out.push(['squeezed into short lines', where(e), Math.round(r.width) + 'px']);
    }
    const typed = (e.tagName === 'INPUT' && /^(text|search|email|url|tel|password)$/.test(e.type)) || e.tagName === 'TEXTAREA';
    if (typed && r.width < 120 && !e.closest('.ui-number, .ui-segments, .ui-code-input, .ui-combobox, .ui-chips, .ui-date-picker')) out.push(['field too narrow to type in', where(e), Math.round(r.width) + 'px']);
  }
  // A zigzag: in a row whose pieces went onto lines of their own, a piece alone on its line and pushed to the far
  // side, under a line that starts at the near side.
  for (const row of document.querySelectorAll('body *')) {
    const cs = getComputedStyle(row);
    if (!/flex/.test(cs.display) || cs.flexWrap === 'nowrap' || /column/.test(cs.flexDirection)) continue;
    const kids = [...row.children].filter((k) => k.getBoundingClientRect().width && !/absolute|fixed/.test(getComputedStyle(k).position));
    if (kids.length < 2) continue;
    const rtl = cs.direction === 'rtl';
    const near = (r) => (rtl ? -r.right : r.left);
    const far = (r) => (rtl ? -r.left : r.right);
    const box = row.getBoundingClientRect();
    const start = near(box) + parseFloat(rtl ? cs.paddingRight : cs.paddingLeft);
    const end = far(box) - parseFloat(rtl ? cs.paddingLeft : cs.paddingRight);
    for (let i = 1; i < kids.length; i++) {
      const a = kids[i - 1].getBoundingClientRect(), b = kids[i].getBoundingClientRect();
      const next = kids[i + 1] && kids[i + 1].getBoundingClientRect();
      if (b.top < a.bottom - 1 || (next && next.top < b.bottom - 1)) continue;
      const above = kids.slice(0, i).map((k) => k.getBoundingClientRect()).filter((q) => q.bottom > a.top + 1 && q.top < a.bottom - 1);
      if (near(b) - start > 24 && end - far(b) < 8 && Math.min(...above.map(near)) - start < 8) out.push(['wrapped to the far side, a zigzag', where(kids[i])]);
    }
  }
  return out;
})();
```

11. **Do not edit the files in `components/ui/`.** Compose them. If something is truly missing, add a new file next to them, built from the same tokens.
12. **The theme is set in one place.** No `data-theme="dark"` on `<html>`, no overriding knobs in CSS, no colours chosen screen by screen: the theme is one value, given once in the root layout (see The theme).
13. **Nothing touches an edge, or its neighbour.** Text, a picture or a control never sits against the border of the box it is in, and two things never sit flush against each other: the kit's containers and lists space what is in them. Words never start a button's padding to the right of everything else either: a clear button with words has a fill of its own, or sits in a bar that has one (`Menubar` draws its bar; a `NavigationMenu` on its own fills its links). And words never sit straight on a painted pattern (see Patterns). The kit's containers keep their own room (`Card` with `CardHeader` / `CardBody`, `Dialog`, `Popover`, `Alert`, `ListItem`, `Inset`), and a card pads whatever is put into it loose; on the page, `Container` keeps the room at the sides. Neither is a reason to put something in a card (rule 15). A box of your own (anything you give a border, a background or a corner) takes `padding: var(--ui-pad)`, or `--ui-pad-sm` for a small one. Open every screen and run the edge check below in the page; it must return an empty list.

```js
// Paste into the browser console, or run with a browser tool. Lists text that sits against the edge of its box, and controls that stick out of it.
// A side counts when it has a border, or when the box is filled and has corners. A rule (a line on one side) only counts on that side.
(() => {
  const out = [];
  const px = (v) => parseFloat(v) || 0;
  const filled = (cs) => !/rgba?\(0, 0, 0, 0\)|transparent/.test(cs.backgroundColor);
  for (const box of document.querySelectorAll('body *')) {
    const cs = getComputedStyle(box);
    const solid = filled(cs) && px(cs.borderTopLeftRadius) > 0;
    const sides = { Top: 0, Right: 0, Bottom: 0, Left: 0 };
    for (const side in sides) sides[side] = solid || (px(cs[`border${side}Width`]) > 0 && !/rgba\(0, 0, 0, 0\)|transparent/.test(cs[`border${side}Color`]));
    const r = box.getBoundingClientRect();
    if (!Object.values(sides).some(Boolean) || r.width < 48 || r.height < 24 || cs.visibility === 'hidden' || cs.overflow !== 'visible' || cs.display === 'inline') continue;
    const walker = document.createTreeWalker(box, NodeFilter.SHOW_TEXT);
    for (let n = walker.nextNode(); n; n = walker.nextNode()) {
      if (!n.textContent.trim() || n.parentElement.closest('.ui-sr-only')) continue;
      // Text in a layer fixed over the page (a menu or drawer kept inside the box in the code) is not in the box.
      let layered = false;
      // So is text in a box inside it that scrolls (a table that scrolls sideways, a carousel, a list in a scroll area): it is cut there on purpose.
      for (let e = n.parentElement; e && e !== box; e = e.parentElement) { const es = getComputedStyle(e); if (es.position === 'fixed' || (es.overflow !== 'visible' && (e.scrollWidth > e.clientWidth + 1 || e.scrollHeight > e.clientHeight + 1))) { layered = true; break; } }
      if (layered) continue;
      const range = document.createRange();
      range.selectNodeContents(n);
      const t = range.getBoundingClientRect();
      if (!t.width || !t.height) continue;
      const gaps = [];
      if (sides.Left) gaps.push(t.left - r.left - px(cs.borderLeftWidth));
      if (sides.Right) gaps.push(r.right - t.right - px(cs.borderRightWidth));
      if (sides.Top) gaps.push(t.top - r.top - px(cs.borderTopWidth));
      if (sides.Bottom) gaps.push(r.bottom - t.bottom - px(cs.borderBottomWidth));
      const gap = Math.min(...gaps);
      if (gap > -2 && gap < 2.5) {
        out.push(`${box.tagName.toLowerCase()}.${String(box.className).split(' ')[0]}: "${n.textContent.trim().slice(0, 40)}" is ${Math.round(gap)}px from the edge`);
        break;
      }
    }
  }
  // A button or a field pushed out of the row it is in: it has eaten the room its box keeps at the side.
  for (const el of document.querySelectorAll('button, a.ui-btn, input, select, textarea')) {
    const e = el.getBoundingClientRect();
    const row = el.parentElement;
    if (!row || !e.width || /absolute|fixed/.test(getComputedStyle(el).position) || getComputedStyle(row).overflowX !== 'visible' || getComputedStyle(row).display === 'contents') continue;
    const r = row.getBoundingClientRect();
    const over = Math.max(r.left - e.left, e.right - r.right);
    if (over > 1) out.push(`${row.tagName.toLowerCase()}.${String(row.className).split(' ')[0]}: a ${el.tagName.toLowerCase()} is pushed ${Math.round(over)}px out of its row`);
  }
  // An icon set against its word: an icon and the text beside it with no room between them (a row whose icon and
  // word were wrapped together, so the row's gap no longer reaches them).
  for (const icon of document.querySelectorAll('.ui-icon')) {
    const i = icon.getBoundingClientRect();
    if (!i.width || !i.height || icon.closest('.ui-sr-only') || /absolute|fixed/.test(getComputedStyle(icon).position)) continue;
    for (const dir of ['previousSibling', 'nextSibling']) {
      let n = icon[dir];
      while (n && ((n.nodeType === 3 && !n.textContent.trim()) || n.nodeType === 8)) n = n[dir];
      if (!n || (n.nodeType !== 3 && n.nodeType !== 1) || !n.textContent.trim()) continue;
      // A name folded away beside its icon (the dock's closed sections) is not on screen.
      if (n.nodeType === 1 && (n.matches('.ui-sr-only, .ui-icon') || n.querySelector('svg, img, input, button') || /absolute|fixed/.test(getComputedStyle(n).position) || n.getBoundingClientRect().width < 2)) continue;
      const range = document.createRange();
      range.selectNodeContents(n);
      // The line of the text that is next to the icon: its first when it follows, its last when it comes before.
      const lines = [...range.getClientRects()].filter((r) => r.width && r.height);
      const t = dir === 'nextSibling' ? lines[0] : lines[lines.length - 1];
      if (!t || Math.min(t.bottom, i.bottom) - Math.max(t.top, i.top) < 4) continue;
      const gap = Math.max(t.left - i.right, i.left - t.right);
      if (gap > -1 && gap < 3) out.push(`${icon.parentElement.tagName.toLowerCase()}.${String(icon.parentElement.className).split(' ')[0]}: an icon touches "${n.textContent.trim().slice(0, 30)}" (${Math.round(gap)}px between them)`);
    }
  }
  // Two things stacked or side by side with no room between them: a field right under a line of text, two toasts.
  // Boxes the kit joins on purpose (button groups, segmented controls, a field and its addons, cells) are left alone.
  const box = (el) => {
    const cs = getComputedStyle(el);
    return (filled(cs) && px(cs.borderTopLeftRadius) > 0) || (px(cs.borderTopWidth) > 0 && !/rgba\(0, 0, 0, 0\)|transparent/.test(cs.borderTopColor));
  };
  const joined = '.ui-btn-group:not(.ui-btn-group--wrap), .ui-segmented, .ui-input-group, .ui-cells, .ui-tabs-list, .ui-split-bar, .ui-bars, .ui-pagination, table, .ui-list, .ui-code-input, .ui-waterfall, .ui-avatar-group';
  const round = (el) => px(getComputedStyle(el).borderTopLeftRadius) > 0;
  for (const el of document.querySelectorAll('body *')) {
    const next = el.nextElementSibling;
    if (!next || el.parentElement.closest(joined) || el.parentElement.matches(joined)) continue;
    if (!box(el) && !box(next)) continue;
    // Bold, code and links inside one line of text are text: the line's own spacing sets them apart.
    if (getComputedStyle(el).display === 'inline' && getComputedStyle(next).display === 'inline') continue;
    // Rows of one kind divided by lines (settings rows, accordion items) are meant to meet; rounded boxes (toasts, cards) are not.
    if (el.className && el.className === next.className && !round(el) && !round(next)) continue;
    const a = el.getBoundingClientRect();
    const b = next.getBoundingClientRect();
    if (!a.width || !a.height || !b.width || !b.height || [el, next].some((n) => /absolute|fixed/.test(getComputedStyle(n).position))) continue;
    const across = Math.min(a.right, b.right) - Math.max(a.left, b.left) > 8;
    const down = Math.min(a.bottom, b.bottom) - Math.max(a.top, b.top) > 8;
    const gap = across ? b.top - a.bottom : down ? b.left - a.right : Infinity;
    // A part with no frame of its own keeps its room inside (a card's body above its footer): that room counts.
    const room = (box(el) ? 0 : px(getComputedStyle(el)[across ? 'paddingBottom' : 'paddingRight'])) + (box(next) ? 0 : px(getComputedStyle(next)[across ? 'paddingTop' : 'paddingLeft']));
    if (gap > -1 && gap + room < 2) out.push(`${el.parentElement.tagName.toLowerCase()}.${String(el.parentElement.className).split(' ')[0]}: "${(el.textContent || el.tagName).trim().slice(0, 30)}" touches the next thing (${Math.round(gap)}px)`);
  }
  // Text that is cut or covered: words that run past their own box (a label squeezed by a field beside it), and things
  // in a row that sit on top of each other. Text that ends in "…" on purpose (ui-truncate) is fine.
  for (const el of document.querySelectorAll('body *')) {
    const words = [...el.childNodes].filter((n) => n.nodeType === 3 && n.textContent.trim());
    const cs = getComputedStyle(el);
    if (!words.length || cs.display === 'inline' || cs.textOverflow === 'ellipsis' || el.closest('.ui-sr-only')) continue;
    const r = el.getBoundingClientRect();
    // A label clipped to a pixel is for screen readers; text in a box that scrolls sideways (code) is meant to.
    if (!r.width || (r.width <= 2 && cs.overflow !== 'visible') || el.closest('pre, .ui-pre, .ui-scroll, .ui-table-wrap, .ui-fade-x')) continue;
    for (const n of words) {
      const range = document.createRange();
      range.selectNodeContents(n);
      const t = range.getBoundingClientRect();
      if (t.width && (t.right > r.right + 1 || t.left < r.left - 1)) {
        out.push(`${el.tagName.toLowerCase()}.${String(el.className).split(' ')[0]}: "${n.textContent.trim().slice(0, 30)}" runs out of its box`);
        break;
      }
    }
  }
  for (const row of document.querySelectorAll('body *')) {
    const cs = getComputedStyle(row);
    if (!/flex|grid/.test(cs.display) || row.closest(joined)) continue;
    const kids = [...row.children].filter((k) => !/absolute|fixed/.test(getComputedStyle(k).position) && k.getBoundingClientRect().width);
    for (let i = 1; i < kids.length; i++) {
      const a = kids[i - 1].getBoundingClientRect();
      const b = kids[i].getBoundingClientRect();
      const sameLine = Math.min(a.bottom, b.bottom) - Math.max(a.top, b.top) > 4;
      if (sameLine && a.right - b.left > 1 && b.left > a.left) out.push(`${row.tagName.toLowerCase()}.${String(row.className).split(' ')[0]}: two things overlap by ${Math.round(a.right - b.left)}px`);
    }
  }
  // Words straight on a painted pattern: its colours change under every letter. They need a solid box under them
  // (a Card, the panel of a Cover, an Empty with `solid`). A letter on a person's painted picture is the kit's own.
  for (const art of document.querySelectorAll('.ui-pattern')) {
    const a = art.getBoundingClientRect();
    const home = art.parentElement;
    if (!home || a.width < 48 || a.height < 48 || art.closest('.ui-avatar')) continue;
    for (const el of home.querySelectorAll('*')) {
      if (art.contains(el) || el.closest('.ui-sr-only, [aria-hidden="true"]')) continue;
      if (![...el.childNodes].some((n) => n.nodeType === 3 && n.textContent.trim().length > 1)) continue;
      const r = el.getBoundingClientRect();
      if (!r.width || !r.height || r.right < a.left + 8 || r.left > a.right - 8 || r.bottom < a.top + 8 || r.top > a.bottom - 8) continue;
      let onSolid = false;
      for (let p = el; p && p !== home; p = p.parentElement) {
        const cs = getComputedStyle(p);
        if (filled(cs) || cs.backgroundImage !== 'none') { onSolid = true; break; }
      }
      if (!onSolid) out.push(`${el.tagName.toLowerCase()}.${String(el.className).split(' ')[0]}: "${el.textContent.trim().slice(0, 30)}" is written straight on a painted pattern`);
    }
  }
  // A number cut inside its field ("90" of 900), and a figure, amount or date broken across lines ("11 / days").
  for (const el of document.querySelectorAll('.ui-number input, input[type="number"]')) {
    if (el.getBoundingClientRect().width && el.scrollWidth > el.clientWidth + 1) out.push(`${el.getAttribute('aria-label') || 'number field'}: "${el.value}" is cut`);
  }
  // A text field squeezed too narrow to type in (a field in a table cell on a phone).
  for (const el of document.querySelectorAll('input.ui-input, .ui-input-group:not(.ui-number)')) {
    const w = el.getBoundingClientRect().width;
    if (w && w < 64 && getComputedStyle(el).display !== 'none') out.push(`${el.getAttribute('aria-label') || el.querySelector('input')?.getAttribute('aria-label') || 'text field'}: squeezed to ${Math.round(w)}px`);
  }
  for (const el of document.querySelectorAll('.ui-stat-value, .ui-figure, .ui-mono')) {
    if (!el.textContent.trim() || !el.getBoundingClientRect().width) continue;
    const range = document.createRange();
    range.selectNodeContents(el);
    const tops = new Set([...range.getClientRects()].filter((r) => r.width > 1).map((r) => Math.round(r.top)));
    if (tops.size > 1 && getComputedStyle(el).whiteSpace !== 'normal') out.push(`${el.className.split(' ')[0]}: "${el.textContent.trim().slice(0, 30)}" breaks across lines`);
  }
  // A stack that spreads its rows apart because a neighbour made it taller (a label far above its field).
  for (const el of document.querySelectorAll('body *')) {
    const cs = getComputedStyle(el);
    if (!/\bui-/.test(el.className) || cs.display !== 'grid' || cs.alignContent !== 'normal' || cs.gridTemplateRows.split(' ').length < 2) continue;
    const kids = [...el.children].filter((k) => k.getBoundingClientRect().height);
    if (kids.length < 2) continue;
    const r = el.getBoundingClientRect();
    const top = Math.min(...kids.map((k) => k.getBoundingClientRect().top));
    const bottom = Math.max(...kids.map((k) => k.getBoundingClientRect().bottom));
    const used = bottom - top + px(cs.paddingTop) + px(cs.paddingBottom) + px(cs.borderTopWidth) + px(cs.borderBottomWidth);
    if (r.height - used > 4 && top - r.top - px(cs.paddingTop) - px(cs.borderTopWidth) > 2) out.push(`${el.tagName.toLowerCase()}.${String(el.className).split(' ')[0]}: its rows are spread apart (${Math.round(r.height - used)}px)`);
  }
  // A box inside a rounded box: at each corner that sits near the outer one, the inner curve must follow the outer
  // curve, the outer corner less the room between them. Too round and it bulges toward the edge; too square and the
  // room swells at the corner (an inset with small corners at the foot of a very round card).
  const rounded = (el) => { const cs = getComputedStyle(el); return px(cs.borderTopLeftRadius) > 0 && (filled(cs) || px(cs.borderTopWidth) > 0) && cs.display !== 'inline'; };
  for (const inner of document.querySelectorAll('body *')) {
    if (!rounded(inner) || inner.closest('.ui-btn, .ui-chip, .ui-badge, .ui-avatar, .ui-switch, .ui-checkbox, .ui-radio, .ui-input, .ui-input-group, .ui-segmented, .ui-bar, button, input')) continue;
    let outer = inner.parentElement;
    while (outer && !rounded(outer)) outer = outer.parentElement;
    if (!outer || !/\bui-/.test(outer.className)) continue;
    const a = inner.getBoundingClientRect();
    const b = outer.getBoundingClientRect();
    if (a.width <= 64 || a.height <= 40) continue;
    const ci = getComputedStyle(inner);
    const co = getComputedStyle(outer);
    const corners = [['TopLeft', a.left - b.left, a.top - b.top], ['TopRight', b.right - a.right, a.top - b.top], ['BottomLeft', a.left - b.left, b.bottom - a.bottom], ['BottomRight', b.right - a.right, b.bottom - a.bottom]];
    for (const [corner, x, y] of corners) {
      const R = px(co[`border${corner}Radius`]);
      const r = px(ci[`border${corner}Radius`]);
      if (x < 0 || y < 0 || x >= R || y >= R) continue;
      const tooRound = r > Math.max(R - Math.min(x, y), R * 0.4) + 3;
      const tooSquare = R - Math.max(x, y) > 8 && r < R - Math.max(x, y) - 4;
      if (tooRound || tooSquare) {
        out.push(`${inner.tagName.toLowerCase()}.${String(inner.className).split(' ')[0]}: ${corner} corner ${Math.round(r)}px inside ${Math.round(R)}px with ${Math.round(Math.max(x, y))}px between: ${tooRound ? 'too round' : 'too square'} (use --ui-radius-inner, or the outer corner less the room between)`);
        break;
      }
    }
  }
  // A choice that hides some of its options past its edge: every option must be in view.
  for (const el of document.querySelectorAll('.ui-segmented, .ui-btn-group, .ui-toolbar')) {
    if (el.scrollWidth > el.clientWidth + 1) out.push(`${el.className.split(' ')[0]}: its options do not fit (${el.scrollWidth - el.clientWidth}px hidden)`);
  }
  return [...new Set(out)];
})();
```

14. **Nothing jumps, nothing just changes.** Anything that switches (a month, a tab, a step, a period, a filter, a row that is added, a badge that changes) fades in: the kit's `Calendar`, `DatePicker` and `TabsPanel` do it themselves; for your own, give the new content `className="ui-appear"` and a `key` that changes with it. Values that follow the hand while it moves (a slider being dragged, text being typed) update live. Something that opens or closes in a row or column (a label, a panel) moves by its true size: a grid track from `0fr` to `1fr`, or the kit's `Collapsible`; never by animating `max-width` or `max-height`, which makes the box swell and then settle. Boxes grow and shrink smoothly when their content changes (Toaster starts this for the page; never turn it off), dialogs fade out before what they changed appears (`afterClose`), and a row that scrolls sideways (tabs, a `Carousel` with `bleed`) runs to the edges of its card instead of being cut at the padding line. Going from page to page is smooth too: the page fades out and the next fades and rises in, while the app's `Sidebar`, a site's `SiteHeader` and the `TabBar` stay still. The kit's CSS does it for a site of plain pages (`@view-transition`); in an app with client routing (Next.js), wrap each page's content in `<PageTransition>` in every `page.tsx` (not the layout, which stays from page to page). A page that arrives on its own (a first visit, a reload, a typed address, a link from somewhere else, a browser without view transitions) fades in as well: the page's colour is there at once and everything on it comes up together. The kit's CSS does that by itself for every page that loads it, with no class and no script, so never hide a page until its scripts have run and never set `opacity`, `transition` or `animation` on `body`. What comes after the page is on screen comes softly too: a `Pattern` fades in over its gradient when it is painted, and the fonts are loaded with the page (`next/font`, or a `preload` link for each font the first screen uses) so text does not change shape after it shows. Never give a page its own entrance animation instead, and never animate the whole screen in some other way.

15. **A card is one thing you can point at.** A `Card` lifts something out of the page, so it has to be one thing: an item a person picks, opens or acts on (a room, an order, a file, a plan), or one task done in one place (a booking form, a group of settings, a sign-up). Everything else sits straight on the page, under its section's title. Ask of every card: if the box were taken away and what is in it left on the page, would anything be lost? If not, leave the card out.
    - **On the page, not in cards:** introductions and text; a row of facts (`Stat`s in a `Grid`); quotes and reviews (the words, the `Rating` and the person, in a `Grid`); details (`DescriptionList`); questions (`Accordion`); pictures (`Picture`, or a `Carousel` of them); steps and features (`ui-icon-tile` with `ItemText`).
    - **A box already:** `Accordion`, `Cells`, `Table`, `List`, `Alert`, `Calendar`, `FileDrop`, `Inset` and `Empty` draw their own box. Never put one alone in a card: that is a box in a box.
    - **A row of the same kind is not a row of cards** unless each is an item to pick. Three rooms with a price and a Choose button are cards; three reviews, four facts or the steps of a process are a `Grid` on the page.
    - **Fields need a surface.** Fields, steppers, segmented controls and `Cells` are filled with the quiet grey, which is the page's own colour: straight on the page they cannot be seen until hovered. A form is a task, so it goes in a card or a dialog.
    - **How many.** A working screen of an app (a dashboard, an editor) is mostly cards, because each panel is a task. A public page (a landing page, a menu, a profile) has few: on a landing page, the booking form and the things to choose. A landing page where most sections are cards reads as a wall of boxes.

    Run this check on every screen too; it must return an empty list.

```js
// Lists cards that need not be cards, and boxes that cannot be seen because they are the colour of what is behind them.
(() => {
  const out = [];
  const name = (el) => `${el.tagName.toLowerCase()}.${String(el.className).split(' ')[0]}`;
  const words = (el) => (el.textContent || '').trim().replace(/\s+/g, ' ').slice(0, 40);
  const shown = (el) => { const r = el.getBoundingClientRect(); return r.width > 0 && r.height > 0 && getComputedStyle(el).visibility !== 'hidden'; };
  // The kit's components that draw a box of their own.
  const boxes = '.ui-accordion, .ui-cells, .ui-table-wrap, .ui-list, .ui-alert, .ui-calendar, .ui-filedrop, .ui-inset, .ui-empty, .ui-pre, .ui-tree, .ui-listbox, .ui-board, .ui-waterfall';
  // What makes a card an item or a task: something a person can do in it (a read-only rating's hidden buttons do not
  // count). A number or a chart is the content of a panel; a picture with words and nothing to do is not an item.
  const controls = 'a[href], button, input:not([type="hidden"]), select, textarea, [role="slider"], [role="radio"], [role="checkbox"], [role="switch"], [role="combobox"], [tabindex="0"], [aria-haspopup], [data-slot="menu-context-trigger"]';
  const acts = (card) => card.matches(controls) || [...card.querySelectorAll(controls)].some((c) => shown(c) && !c.disabled && !c.readOnly && !c.closest('[aria-hidden="true"], [data-readonly], [aria-readonly="true"]'));
  const panel = '.ui-figure, .ui-stat, .ui-bars, .ui-chart, .ui-meter, .ui-progress, progress, table';
  const pictures = 'img, video, .ui-pattern:not(.ui-avatar)';
  for (const card of document.querySelectorAll('.ui-card')) {
    // A picture made of components and hidden from screen readers (aria-hidden) is an illustration, not a page.
    if (!shown(card) || card.closest('[aria-hidden="true"]')) continue;
    const parts = [...card.children].filter(shown).flatMap((p) => (p.matches('.ui-card-header, .ui-card-body, .ui-card-footer') ? [...p.children].filter(shown) : [p]));
    if (parts.length === 1 && parts[0].matches(boxes)) out.push(`${name(card)} "${words(card)}": holds only ${name(parts[0])}, which is a box already. Leave the card out.`);
    else if (!acts(card) && !card.querySelector(panel)) out.push(card.querySelector(pictures)
      ? `${name(card)} "${words(card)}": a picture and words with nothing to do. Use a Picture on the page; a card is for an item to pick or a task.`
      : `${name(card)} "${words(card)}": only text in a card. Put it on the page, under its section's title.`);
  }
  // A filled box with no line or shadow, the same colour as what is behind it: a field on the bare page.
  const paint = document.createElement('canvas').getContext('2d', { willReadFrequently: true });
  // A colour as red, green, blue, alpha; null when this browser's canvas cannot read it (an older Firefox and oklch).
  const rgba = (c) => { paint.clearRect(0, 0, 1, 1); paint.fillStyle = '#010203'; paint.fillStyle = c; if (paint.fillStyle === '#010203') return null; paint.fillRect(0, 0, 1, 1); return [...paint.getImageData(0, 0, 1, 1).data]; };
  const colours = (v) => v.match(/(?:rgba?|hsla?|oklch|oklab|lab|lch|color)\([^()]*\)/g) || [];
  const visible = (c) => { const v = rgba(c); return !v || v[3] > 8; };
  const behind = (el) => {
    for (let p = el.parentElement; p; p = p.parentElement) { const c = getComputedStyle(p).backgroundColor; if (visible(c)) return rgba(c); }
    return [255, 255, 255, 255]; // nothing painted behind: the browser's white
  };
  for (const el of document.querySelectorAll('[class*="ui-"]')) {
    const cs = getComputedStyle(el);
    // Inline words with a tint (code in a sentence) are not boxes.
    // A box still fading in or out (a header turning into a bar) is judged once it has settled.
    if (!shown(el) || cs.display === 'inline' || !visible(cs.backgroundColor) || el.closest('.ui-sr-only') || el.getAnimations().some((x) => x.playState === 'running')) continue;
    const r = el.getBoundingClientRect();
    if (r.width < 24 || r.height < 16) continue;
    const lined = ['Top', 'Right', 'Bottom', 'Left'].some((s) => parseFloat(cs[`border${s}Width`]) > 0 && visible(cs[`border${s}Color`])) || (cs.outlineStyle !== 'none' && parseFloat(cs.outlineWidth) > 0 && visible(cs.outlineColor)) || colours(cs.boxShadow).some(visible);
    if (lined) continue;
    const a = rgba(cs.backgroundColor);
    const b = behind(el);
    if (!a || !b) continue; // a colour this browser cannot read: not judged here
    const mix = a.slice(0, 3).map((v, i) => (v * a[3] + b[i] * (255 - a[3])) / 255);
    if (mix.every((v, i) => Math.abs(v - b[i]) < 3)) out.push(`${name(el)} "${words(el)}": its fill is the colour of what is behind it, so it cannot be seen. Put it on a surface (a card or a dialog).`);
  }
  return [...new Set(out)];
})();
```

16. **One sentence, no full stop.** A text on screen that is a single sentence ends without a full stop: a banner ("Your trial ends in 3 days"), a toast or alert line, a field hint or error, a card or dialog description, an empty state, a caption, a list item, a heading. As soon as a text has two sentences or more, every sentence ends with one ("At the studio, after your visit. We take cards and cash."). A question still ends with "?", and something said with feeling may keep "!". This is a choice made while writing, not a rule to run over the finished text: words that someone else wrote keep their own marks (a review, a quote, a message from a customer), and so does any text the person asked to read a certain way. When the person asks for full stops, use them.

## The theme

The look is one small value, the **theme**: what things are made of, three plain choices of colour and a few numbers.

```json
{ "style": "simple", "brand": "#c2eb32", "greys": "neutral", "page": "soft", "radius": 20, "density": 1, "stroke": 1.5, "mode": "light", "font": "inter", "width": "regular" }
```

| Key | Values | What it does |
|---|---|---|
| `style` | `simple` | The theme: what everything is made of (depth, edges, sheen). `simple` is flat layers and soft lines. More themes come with new versions of the kit (`themeStyles` lists the ones this copy has); one this copy does not have falls back to Simple. It is switched on at `<html>` with `{...themeAttributes(theme)}` (plain HTML: `data-ui-style="simple"`) |
| `brand` | any colour, as `#rrggbb` | The brand colour, used exactly as picked: the primary button, links, progress, charts. Text on it turns black or white by itself. In dark mode it is a step lighter, and a brand without colour (black, white, a grey) turns over, so a black button becomes a white one |
| `greys` | `neutral`, `warm`, `cool`, `brand` | The greys of lines, quiet fills and text: pure grey, a little warm, a little cool, or carrying a little of the brand colour |
| `page` | `white`, `soft`, `grey` | How bright the page behind the cards is, shown to people as Bright, Soft (the default) and Deep: pure white, a soft grey or a deeper grey in light mode, and the same three steps of dark in dark mode. Cards are always white in light mode |
| `radius` | 0–28 | Corners, in px: 0 is square, 28 is very round. From 20 up, buttons and fields become pills |
| `density` | 1–1.3 | Size of controls, gaps and text: regular to large |
| `stroke` | 1–2.5 | Line weight of icons beside regular text, thin to bold; 1.75 (the default) matches Inter's own strokes. Beside medium or bold text icons get heavier by themselves, so an icon is always as heavy as the words next to it |
| `mode` | `light`, `dark`, `system` | Light by default; `system` follows the visitor's device |
| `font` | `inter`, `dm` | The font pair: `inter` is Inter with Reddit Mono (the default), `dm` is DM Sans with Courier Prime |
| `width` | `narrow`, `regular`, `wide`, `full` | How wide the page's content runs: 960px, 1120px (the default), 1320px, or the whole window less its side room. Every `Container` follows it (`--ui-page-max`); `Container narrow` stays a reading column. When nobody has said which, choose it from what the pages are for, never leave it to chance: `narrow` for reading and filling in (an article, a sign-up, settings, a booking form, a one-page site of a few sections); `regular` for most sites and apps (a shop, a hotel, a list with details); `wide` for screens that show many things side by side (a dashboard, a gallery, a board, a calendar of the week); `full` for tools that use the whole window (an editor, a canvas, a map, a big table). Say in one line which you chose and why |

There is nothing else to set. What is chosen or switched on is always ink (see The rules), status colours are fixed, and every other colour is worked out.

**Theme code.** The whole theme also fits in one short word, a theme code:

```
sui2-bc2eb32-gn-ps-r12-d100-s175-ml
```

Make a look at `https://www.supply.family/ui/` (Customize, then **Copy for your AI**) to get its code. When you are given a code that starts with `sui2-` (or `sui1-`, the format from before, which is still read):

- Put it in the root layout as it is (`THEME` above). `normalizeTheme` and `ThemeStyle` read a code directly; `themeCode(theme)` turns a theme back into one.
- Do not translate it into colours by hand, and do not change it.
- Its parts: `b` the brand colour as six hex digits · `g` the greys (`n` neutral, `w` warm, `c` cool, `b` brand) · `p` the page (`w` white, `s` soft grey, `g` grey) · `r` corners in px · `d` size ×100 · `s` icon weight ×100 · `m` light, dark or auto (`l`, `d`, `a`) · `f` the font pair: `fd` is DM Sans with Courier Prime, left out is Inter with Reddit Mono · `t` the theme by its name (`tsimple`), left out is Simple · `w` the page width (`wn` narrow, `ww` wide, `wf` full), left out is regular.
- Without React, set the knobs on `:root` yourself. The brand colour goes in as its three OKLCH numbers, which any colour tool gives: `--ui-brand-l` (lightness, 0–1), `--ui-chroma` (strength, 0–0.3), `--ui-hue` (0–360). The greys: `--ui-grey-hue` (70 warm, 250 cool, or the brand's hue) and `--ui-tint` (0 for neutral, 0.012 for warm or cool, 0.014 for brand). The page: `--ui-shade` (0 white, 0.7 soft grey, 1.5 grey). Then `--ui-radius` in px, `--ui-density`, `--ui-icon-stroke`, `--ui-page-max` (`960px`, `1120px`, `1320px` or `none`), `color-scheme` (`light`, `dark` or `light dark`), and for `fd` `--ui-font-sans: var(--ui-font-dm-sans); --ui-font-mono: var(--ui-font-courier-prime)`. So the code above is `--ui-brand-l: 0.881; --ui-chroma: 0.2; --ui-hue: 122; --ui-tint: 0; --ui-shade: 0.7; --ui-radius: 12px; --ui-density: 1; --ui-icon-stroke: 1.75; --ui-page-max: 1120px; color-scheme: light`.

Two more:

- **Build every screen from the kit's classes and components**, never with your own shadows, borders or gradients on cards, buttons and fields: the theme draws those, and a hand-made shadow stays the same when the theme changes. A piece the kit does not have reads the Material tokens (below) for its depth and edges.
- A visitor's own light or dark switch is fine: that is the visitor's choice for their device. The theme's `mode` stays the default. The kit has it ready: `<ColorSchemeSwitch />` (see Helpers).

## Tokens

| Group | Tokens |
|---|---|
| Page and surfaces | `--ui-bg` (page), `--ui-surface` (cards, inputs, popups), `--ui-surface-2` (hover, subtle fill), `--ui-surface-3` (pressed, selected) |
| Lines | `--ui-border` for every line that only shows where something ends: card, cell, list, table, badge, chip, tab underline, divider, connector. One colour everywhere: it is a see-through tint, painted over what is behind a box (`background-clip: padding-box`), so all lines in a card match. A box shows its edge with a fill or with a line, never both: filled boxes (fields of every kind, cells) have no line at rest, only on hover and focus. `--ui-border-solid` is the same line for one drawn over a box's own fill. `--ui-border-hover` is the line on hover (a field, a card, a row, a chip): one gentle step up. A field in use gets `--ui-highlight` with a soft `--ui-focus-halo` around it, never a hard double ring. `--ui-border-strong` only for the edges of controls that must always show (checkbox, radio, switch track, outlined button) and a chosen swatch |
| Text | `--ui-fg`, `--ui-fg-muted` (secondary), `--ui-fg-subtle` (placeholders; not for text people must read) |
| Brand | `--ui-primary` + `--ui-on-primary` (the main action, progress, charts), `--ui-primary-hover`, `--ui-primary-text` (brand colour as text: links), `--ui-primary-soft` (soft background: badges, icon tiles), `--ui-ring` (focus) |
| Ink | `--ui-ink` + `--ui-on-ink` (everything chosen or switched on), `--ui-ink-soft` (a chosen row among many) |
| Status | `--ui-danger`, `--ui-success`, `--ui-warning`, `--ui-info`, each with `-text`, `-soft` and `--ui-on-…` |
| Type | `--ui-font-sans`, `--ui-font-mono`; sizes `--ui-text-xs` `sm` `base` `md` `lg` `xl` `2xl` `3xl`; weights `--ui-weight`, `-medium`, `-bold` |
| Space | `--ui-space-1` `2` `3` `4` `5` `6` `8` `10` `12` `16` (4px steps, scaled by density) |
| Room inside a container | `--ui-pad` (cards), `--ui-pad-lg` (dialogs, large panels), `--ui-pad-sm` (toasts, alerts, code). Grows with Corners, so text never sits in the curve. Use these, not a fixed `--ui-space-…`, for the padding of anything with a large corner |
| Gap between blocks | `--ui-gutter`: the space between cards side by side; `Grid` uses it. `--ui-gap-lg` and `--ui-gap-xl`: between groups and between sections (`gap={6}` and `gap={8}` on `Stack` and `Row`, and the page's margin in `Main`). They shrink on small screens, and they go the opposite way to the theme's Size: bigger controls, tighter gaps between blocks. `--ui-gap-section`: between the sections of a public page, such as a landing page (`gap={12}`); it grows with the window. Use them, never `--ui-space-…`, for the space between blocks of your own |
| Control heights | `--ui-h-sm`, `--ui-h-md`, `--ui-h-lg` |
| Corners | `--ui-radius-sm` (menu rows, cells), `md` (buttons, fields, chips, badges), `lg` (cards, popups), `xl` (dialogs), `box` (small boxes that hold a line or two: toasts, alerts, popups, code; capped so a short box never becomes a pill), `inner` (a box inside a padded container: set by the container, so the two curves follow each other; `nested` is the older fixed step), `round` (avatars, switches, count bubbles: circles at the default, squarer as Corners goes down). `--ui-radius-full` is only for what is round by nature: radio dots, spinners, status dots |
| Depth | `--ui-shadow-sm` `md` `lg`, `--ui-overlay` |
| Material (set by the theme) | Cards: `--ui-card-border`, `--ui-card-shadow`, `--ui-card-raised-shadow`, `--ui-card-fill`. Floating: `--ui-float-border`. Bars over the page (a sticky `SiteHeader`, `Cover`'s panel): `--ui-bar-bg`, always solid. Buttons: `--ui-control-shadow` (and `-hover`, `-active`), `--ui-control-fill`, `--ui-control-press`. Fields: `--ui-field-bg`, `--ui-field-border`, `--ui-field-shadow`. Wells (tracks, the ground under segments): `--ui-well-shadow`. Knobs: `--ui-knob-bg`, `--ui-knob-shadow`. Chosen: `--ui-chosen-shadow`, `--ui-chosen-fill`. A piece of your own uses the one for its role, e.g. `box-shadow: var(--ui-card-shadow); border-color: var(--ui-card-border)` for a panel, so it follows every theme. Read them, never set them. Nothing in the kit is see-through glass: no `backdrop-filter`, no blurred page showing under a bar, menu or panel; every surface is solid (the style check refuses a backdrop blur) |
| Motion | `--ui-dur-fast`, `--ui-dur`, `--ui-dur-slow`, `--ui-ease` |

Pair a background with its own text colour: `--ui-primary` with `--ui-on-primary`, `--ui-ink` with `--ui-on-ink`, `--ui-danger-soft` with `--ui-danger-text`, any surface with `--ui-fg` or `--ui-fg-muted`. Those pairs stay readable for every brand colour.

## Components

Import everything from the folder: `import { Button, Card } from '@/components/ui'` (or a relative path). The class in the last column is what to use without React.

The components can be used straight in a server component. Only a prop that is a function (`onValueChange`, a `cell` of a `Waterfall` column, an `unavailable` rule written as a function) has to come from a file with `'use client'`, as always in Next.js.

### Layout

| Component | Use | Class |
|---|---|---|
| `AppShell`, `Sidebar as`, `Main as` | Sidebar and main area; the sidebar becomes a top strip on a phone. They are the page's `<aside>` and `<main>`; a screen shown inside another page (an example, a preview) passes `as="div"` to both, so the page keeps one main | `ui-app`, `ui-sidebar`, `ui-main` |
| `Burger open` | The two-line button that opens the menu on a small screen; the lines cross into an X when it is open | `button.ui-burger` + `aria-expanded` |
| `Nav`, `NavItem active` | Links in the sidebar. With Next.js `<Link>`, use `className={navItemClass}` and `aria-current="page"`. `Nav variant="rail"`: icons only in a narrow column, the chosen one in ink; give each item an `aria-label` and a `Tooltip` | `ui-nav`, `ui-nav-item`, `ui-nav--rail` |
| `PageHeader` | Title on the left, actions on the right | `ui-page-header` |
| `SitePage header footer` | One page of a site: the header, the page's sections (each a direct child) and the footer in the page column, spaced for you (see The page) | `div.ui-container.ui-site-page` > header + `main.ui-site-main` + `footer.ui-site-footer` |
| `PageTransition` | Wraps one page's content (in Next.js, in each `page.tsx`) so going to it is smooth: the old page fades out, this one fades and rises in, and the sidebar, site header and tab bar stay still. Plain multi-page sites need nothing: the kit's CSS does the same. A page opened on its own (a first visit, a reload) fades in by itself, with or without it | `::view-transition-old(.ui-page)`, `::view-transition-new(.ui-page)`; `@view-transition` |
| `Container narrow` | Centred column for pages without a sidebar, as wide as the theme's `width`; `narrow` is a reading column | `ui-container` |
| `Bleed contained` | A band the full width of the window from inside a `Container`: a tinted section, a row of pictures. What is in it lines up with the page column again; `contained={false}` runs it edge to edge | `div.ui-bleed` > `div.ui-container` |
| `Stack gap={4}` | Things under each other. The gap says how far apart they belong: `1`–`4` inside a group, `6` between groups, `8` between the parts of an app's screen, `12` between the sections of a public page (a landing page's rooms, reviews and questions). A landing page made with `8` reads as one crowded block | `ui-stack` + `ui-gap-4` |
| `Row between center nowrap stretch` | Things next to each other; wraps. They are always lined up on their middles from top to bottom, so nothing is needed for that. `between` spreads them to both ends; `center` moves them all to the middle of the line, left to right (a row of buttons under a centred title), never for lining up; `stretch` makes them as tall as the row: a sidebar beside its content. A text field in a row with its button fills the room the button leaves | `ui-row`, `ui-row--between`, `ui-row--center`, `ui-row--nowrap`, `ui-row--stretch` |
| `Split gap at side` | A side part and a main part next to each other (a sidebar and its page, a rail and its list) that stack when the box is too narrow for the main part to keep `at` of its width (a share like `55%`; a length is never wider than the box). Follows its box, not the window, so it works in a card. Use it, never a one-line row, for anything sidebar-like inside a card | `div.ui-split` + `--split-at`, `--side` |
| `ItemText title note size` | A name and a line under it: a person and their role, a product and its price, a file and its size. Set tight so the two read as one; never build the pair from two loose lines of text. `size="lg"` for the heading of a card | `span.ui-item-text` > `.ui-item-title` + `.ui-item-note`; `ui-item-text--lg` |
| `Grid min="240px" top` | Equal columns, as many as fit. Items in a row grow to the tallest, so cards line up with their footers at the foot; `top` keeps each at its own height (a form beside a tall picture) | `ui-grid` + `--min`, `ui-grid--top` |
| `Separator vertical` | A dividing line | `ui-separator` |

### AI assistants

UI SDK, which the kit stands on, is made for AI in two ways. A coding AI builds components from its behaviours (see Building what the kit does not have). And an AI assistant the person runs can use the finished app: it sees the controls by their names and changes them directly, without clicking through the page. `<AgentBridge />` in the root layout switches the second on; without an assistant it does nothing.

Keep it working:

- **Use the kit's components for every control.** An assistant sees `Button`, `Input`, `Textarea`, `Select`, `Combobox`, `NumberInput`, `Checkbox`, `RadioGroup`, `Switch`, `Slider`, `Toggle`, `ChipButton`, `Choice`, `SearchInput`, `DatePicker`, `Listbox`, `Sortable`, `Board`, `Tree`, `Tabs`, `Menu`, `Dialog`, `Drawer` and the rest. It does not see a plain `<button>`, `<input>` or `<select>` written by hand, nor `NativeSelect` (the browser's own select): use `Select` where an assistant should be able to choose, and `InputGroupInput` for the field inside an `InputGroup`.
- **Name every control.** Put it in a `Field` with a `label`, give it children (`<Switch>Weekly digest</Switch>`), or an `aria-label`. Names should differ from each other on the same screen: an assistant finds a control by its name, and "Tip" and "Custom tip" collide. In a row of a table, name the control for its row: `aria-label="Actions for Jane Doe"`.
- **Keep state in the change callbacks** (`onValueChange`, `onCheckedChange`, `onOpenChange`), not in click or key handlers: an assistant's change does not click. In a callback, `details.source === 'agent'` says the assistant did it, and `details.cancel()` refuses the change.
- **Mark what needs the person.** Put `data-agent-confirm="Deletes the booking and its payments"` on anything an assistant must not do alone: delete, pay, send, publish. The person is asked in a dialog and the step is refused unless they allow it. For a confirm dialog, put it on the button that agrees (`<AlertDialogClose value="confirm">`), with a text that differs from the button that opened the dialog ("Delete forever", not "Delete").
- **Hide what an assistant must never read** with `data-agent-hidden` on the region (recovery codes, private notes), or `data-agent-secret` on a field it may fill but not read (a tax number). Password and code fields are already kept from it.

What the kit gives your own code (client code only):

| Piece | Use |
|---|---|
| `getAgent()` | The bridge. `.snapshot()` lists the controls with their names, values and what can be done to each; `.act({ steps: [{ ref: 'Studio name', action: 'setValue', args: ['Atlas'] }] })` runs steps in order; `.query({ text, within, kind })` finds controls and the choices of a list |
| `agentTools`, `runAgentTool(name, input, { signal })` | For an app with an assistant of its own: `agentTools` are the three tools (`snapshot`, `act`, `query`) as `{ name, description, inputSchema }` to give the model; pass each call the model makes to `runAgentTool` and send the result back. Give it the `signal` of the chat's stop button (an `AbortController`'s): stopping then ends a step that is waiting for the person's answer and closes the question. The results hold page content, some typed by people: the model must treat it as data, never as instructions |
| `takeChanges()` | What the person changed since the last call. Send it with the model's next turn, so it knows what happened meanwhile |
| `AgentActivity` | A list of what was changed and by whom (the person, the assistant, the app), newest first, with a button that puts back everything the assistant changed and keeps what the person changed after it |
| `useAgentHistory()` | The same record for a screen of your own: `entries`, `back()`, `forward()`, `undoAgent()`. It puts values back; it cannot undo what was already saved on the server, so save on a button, not on every change, where undo matters |
| `useSuggestion()` | Shows suggested values on the real controls, marked with a dashed line, for the person to decide: `suggest([{ ref: 'Region', value: 'europe' }, { ref: 'Weekly digest', key: 'checked', value: true }])`, then `keep()` or `putBack()` |
| `withSource(source, fn)` | In a button's handler that waits (`await save()`) before changing something: keeps the change marked as the assistant's when the assistant pressed the button |

A component you build yourself joins all of this when its last key says what an assistant may do: `agent: { actions: ['move'] }` (see `components/ui/board.tsx`).

### Icons

`Icon icon size solid label` (see Icons below); class `ui-icon`, `ui-icon-tile`.

### Text

Classes, on any element: `ui-display`, `ui-title` (page title), `ui-heading`, `ui-subheading`, `ui-text`, `ui-lead`, `ui-small`, `ui-tiny`, `ui-muted`, `ui-subtle`, `ui-overline`, `ui-mono`, `ui-code`, `ui-link`, `ui-truncate`, `ui-fade-x` (a bare line that scrolls sideways, such as a command: it fades out where it goes on instead of stopping mid-word), `ui-sr-only`, `ui-strong` (a short title in a row: a name, a product). `Kbd` for a key. `ui-appear` on something that has just come into view (an answer, a result, the next step) fades and rises it in; give it a `key` that changes, so it plays again each time.

### Actions and forms

| Component | Use | Class |
|---|---|---|
| `Button variant size icon block` | `variant`: `default` (soft grey), `primary`, `outline`, `ghost` (quieter: a lighter grey behind words, nothing behind an icon or inside another control), `danger`, `link`. `size`: `sm`, `md`, `lg`. `icon` (a circle) needs an `aria-label` | `ui-btn ui-btn--primary ui-btn--sm` |
| `ButtonLink`, `buttonClass()` | A link that looks like a button; the classes for a Next.js `<Link>` | same |
| `ButtonGroup` | Buttons joined into one control. Many of them (a 0 to 10 score, the days of a week): add `className="ui-btn-group--wrap"` to it or to a `ToggleGroup`, and they become separate buttons that share the width and wrap onto rows of even length (eleven scores are 6 and 5 on a phone, never 5, 5 and 1) | `ui-btn-group`, `ui-btn-group--wrap` |
| `Toggle pressed defaultPressed onPressedChange` | A button that stays on or off: pin, mute | `ui-btn` + `aria-pressed` |
| `ToggleGroup value defaultValue onValueChange multiple` with `Toggle value` inside | Toggles that share one value: text styles, a view switcher. The value lists the pressed ones. One tab stop, arrows move between them | `ui-btn-group` |
| `CopyButton text` | Copies a link, a code or a command and says "Copied" | (React only) |
| `Button loading` | A spinner, and it cannot be pressed: while a save is under way | `ui-btn` + `ui-spinner` inside, `disabled` |
| `Field label hint error htmlFor` | Label, control, and a hint or error under it. The label names the kit's control inside by itself (`htmlFor` is only for a plain HTML control with an `id`) | `ui-field`, `ui-label`, `ui-hint`, `ui-error` |
| `Fieldset legend` | A named group of fields | `fieldset.ui-fieldset` > `legend.ui-legend` |
| `FormRow title description` | A settings row: what it is on the left, the control on the right | `ui-form-row` > `ui-form-row-text` |
| `Input`, `Textarea` | Text. Mark a wrong value with `aria-invalid="true"` | `ui-input` |
| `InputGroup`, `InputGroupInput`, `InputGroupText` | A field with an icon, a unit ("€", "/ month") or a small button inside; the text field in it is `InputGroupInput` | `ui-input-group`, `ui-input-group-text`, a bare `input` |
| `SearchInput` | A search field with its icon | `ui-input-group` + icon + `input[type=search]` |
| `PasswordInput autoComplete` | A password with a show/hide button. It hides the password again when the form is sent and says when Caps Lock is on. `autoComplete="new-password"` where a password is being set | (React only) |
| `NumberInput min max step` | A number with minus and plus buttons | `ui-input-group ui-number` |
| `DateInput value granularity min max name`, `TimeInput` | A date, or a time, typed one part at a time in the order the person's language writes it: for dates known by heart, like a birthday. `granularity="minute"` adds the time to a date. Values are `"2026-11-02"`, `"2026-11-02T14:30"`, `"14:30"` | (React only; plain HTML uses `input.ui-input[type=date]`) |
| `Calendar value mode min max unavailable marked months selects name` | A month to pick from, when the days themselves matter (a booking). Dates are `"YYYY-MM-DD"`. `mode="range"` picks a start and an end (the value is `[start, end]`), `mode="multiple"` any number of days. `unavailable` takes dates, `{ from, to }`, `{ weekday: [0, 6] }` or a function; `marked` puts a dot on days; `months={2}` shows two side by side; `selects` gives month and year dropdowns | `ui-calendar` > `ui-calendar-grid` > `button.ui-day` |
| `Select items name placeholder` | Designed dropdown, one choice; sends its value with the form. `items` are `{ value, label }`, or groups `{ label, items }`. In a row beside a label it is as wide as its value (at least 8rem), never the whole row | (React only) |
| `MultiSelect items value onValueChange` | The same dropdown for several choices: each press ticks or unticks one | (React only) |
| `Combobox items name placeholder clearable` | A dropdown to type in; use it from about ten options up | (React only) |
| `MultiCombobox items value onValueChange` | Several options chosen by typing; each becomes a chip in the field: people on a task, tags | (React only) |
| `Autocomplete items placeholder clearable` | A text field that suggests while the person types. Any text is a valid value; when it must be one of the options, use `Combobox`. For suggestions from the server, `useAsyncOptions` (see Helpers) | (React only) |
| `Listbox items value multiple name aria-label` | Options that stay in view, one or several: like a dropdown that is always open. `items` are `{ value, label, icon? }` or groups | (React only) |
| `TokenInput triggers placeholder value onValueChange onSubmit name` | Text with tokens in it: people mentioned in a message, files in a prompt, tags. `triggers` say what opens suggestions: `[{ char: '@', type: 'mention', items: people }]`. The value is a list of strings and `{ type, value, label }` tokens | (React only) |
| `TriggerInput triggers` | A plain text field that suggests at the caret after `@`, `/` or `#`; the value stays plain text | (React only) |
| `DatePicker value mode min max clearable presets name` | A field to type a date in, with a calendar to pick it from; a sheet on a phone. `mode="range"` gives a field for each end. `presets` are ready choices under the calendar: `[{ label: 'Today', value: '2026-11-15' }]` | (React only; plain HTML uses `input[type=date]`) |
| `CodeInput length` | A code typed one character per box: a verification code, a PIN | `ui-code-input` > `input` |
| `Rating label name value max step readOnly` | Stars to give a score, or to show one (`readOnly`, where any number shows, like 4.2). `step={0.5}` for half stars | `fieldset.ui-rating` > `label.ui-rating-star` |
| `Choice type title description value` | A radio or checkbox as a whole card: plans, methods. Radio cards go inside a `RadioGroup`, which holds the name and the value; a checkbox card takes `checked`, `onCheckedChange`, `name` | `label.ui-choice` > `ui-choice-text` + input |
| `FileDrop name accept maxSize maxFiles multiple validate hint onFiles` | A box to drop files on, paste them into, or choose them with its button. It checks them, lists what it holds with a cross on each, says why a file was turned away, and sends them with the form | `label.ui-filedrop` + `input[type=file]` |
| `NativeSelect` | The browser's own select, drawn to match. In browsers that allow it, its list is designed and slides open too; elsewhere the browser shows its own list | `select.ui-input` |
| `Checkbox`, `Switch` (`checked`, `defaultChecked`, `onCheckedChange`, `name`), `RadioGroup value defaultValue onValueChange name` with `Radio value` inside | On, off, one of several. `RadioGroup` adds no box of its own: put it in a `Row` or a `Stack`. They are sent with a form under their `name`. Children become the label | `ui-checkbox`, `ui-radio`, `ui-switch` inside `label.ui-check` |
| `CheckboxGroup value defaultValue onValueChange` with `Checkbox value` inside | Several of several, kept as one list of values | `ui-checkbox` inside `label.ui-check` |
| `Slider min max step value defaultValue onValueChange name` | A number in a range | `input.ui-range` |
| `RangeSlider value onValueChange labels showValue format` | A slider with two ends: a price from and to. The value is `[from, to]` | (React only) |
| `Sortable items value onValueChange aria-label` | A list the person puts in order by dragging rows, or with Space and the arrows. `items` are `{ id, content }`; `onValueChange` gets the ids in their new order: save that | (React only) |
| `Board columns cards value onValueChange aria-label` | Columns of cards moved by dragging, or with Space and the arrows: bookings by status, tasks. `columns` are `{ id, title, limit? }`, `cards` `{ id, content }`, the value `{ columnId: [cardIds] }`. `onValueChange` also gets what moved: save that. A full column refuses another card | (React only) |
| `Tree items value onValueChange defaultExpanded checkable checked onCheckedChange aria-label` | Things inside things: folders and files, categories. `items` are `{ id, label, children? }`. `checkable` puts a checkbox on every row; ticking a branch ticks what is in it | (React only) |
| `ColorPicker value onValueChange swatches eyeDropper name` | Pick any colour, as a CSS colour like `#0ea5e9`. Not for the theme, which is set in one place | (React only) |
| `ImageCropper src alt aspectRatio shape onCropCommit` | Choose the part of a picture to keep. `onCropCommit` gets the crop in the picture's own pixels: do the cutting on the server | (React only) |
| `ResizablePanels`, `ResizablePanel defaultSize minSize`, `ResizableHandle aria-label` | Panels side by side the person resizes: a list beside its detail. Give `ResizablePanels` a height. Narrower than 560px (a phone, a side column) the panels stack at their own height and the handle becomes a line. Straight in a `Card`, the card is its frame | (React only) |
| `Segmented items value onValueChange` | Two to five choices, one always chosen. Its options are all one width where there is room; where there is not, each keeps the width of its word, and on a small phone the room round each word shrinks. Only a row too long for its box scrolls | `ui-segmented`, `ui-segmented-item` |
| `ChipButton tone pressed onPressedChange` | A filter that is on or off; a row of them filters a list | `button.ui-chip` + `aria-pressed` |

### Showing things

| Component | Use | Class |
|---|---|---|
| `Card`, `CardHeader`, `CardTitle`, `CardDescription`, `CardBody`, `CardFooter` | One thing lifted out of the page: an item a person picks or acts on (a room, an order, a file), or one task (a form, a group of settings). Not for a section, text, facts, quotes or questions: those sit on the page (rule 15). Never a card in a card, nor a card round a component that is a box already. Cards in a row are one height and their `CardFooter` sits at the foot, so their buttons line up: keep a card's price and button in its footer | `ui-card…` |
| `Stat label value note icon` | One number with its label. Open, with no box: a row of them in a `Grid` is the facts of a page. `icon` (a Lucide icon) sits in a soft tile over it | `ui-stat…`, `ui-icon-tile` first inside |
| `Figure size` | One very large, light number: the main fact of a card | `ui-figure`, `ui-figure--sm` |
| `Cells`, `Cell label` | Small facts side by side, each a label over a value, inside a card or a dialog (they are filled with the page's own grey, so on the page they cannot be seen: use `Stat`s there). They share their rows evenly, and a last row with fewer of them fills its width | `ui-cells` > `ui-cell` > `ui-cell-label` |
| `Inset` | A quieter panel inside a card, for a second group | `ui-inset` |
| `Bars values highlight hatch label labels` | A small bar chart; the bar that matters is in the brand colour, the rest plain or hatched. `labels`: a short name under each bar | `ui-bars` > `ui-bar` + `--value`, `ui-bar--primary`, `ui-hatch`; `ui-bars-labels` under it |
| `Chip tone size` | A category or a tag, with an optional icon. `tone` is a hue (0–360) | `ui-chip ui-chip--tone` + `--tone` |
| `Table scroll` | Data in rows. Plain `<thead>`, `<tr>`, `<th>`, `<td>` inside; `className="ui-num"` on number cells. Where its columns do not fit, each row becomes a block: the first cell is its title, every other cell a line with its column's name (a heading in `ui-sr-only` names none: such cells share one line). With `scroll` it keeps its columns and scrolls sideways instead | `ui-table-wrap` > `ui-table` |
| `Badge tone dot pill` | A status word. `tone`: `neutral`, `primary`, `success`, `warning`, `danger`, `info`, `outline` | `ui-badge ui-badge--success` |
| `Avatar name src size` | A person. The initials show while the picture loads, and stay if it fails or there is none | `ui-avatar` |
| `PatternAvatar name size` | A person or a thing without a photo: a small painted circle, always the same for the same name | `ui-avatar ui-pattern` + `data-pattern` |
| `AvatarGroup` | Avatars overlapping in a row | `ui-avatar-group` |
| `Pattern seed palette look`, `CardCover seed` | A painted picture (see Patterns below) | `ui-pattern` + `data-pattern`, `ui-card-cover` |
| `Cover seed image bleed size align` | The top of a public page: a picture (painted from `seed`, or `image={<img … />}`) filling a band the width of the window, with a solid panel over it holding a title, a line and a button or a small form. `size`: `md`, `lg` (default), `full`. `align="center"` puts the panel in the middle. `bleed={false}` keeps it a rounded block in the column. Text never sits straight on the picture | `section.ui-cover.ui-bleed` > `.ui-cover-media` + `.ui-cover-inner.ui-container` > `.ui-cover-panel` |
| `Picture seed ratio` | A picture on its own, with the kit's corners: in a section, a carousel, beside text. Painted from `seed`, or a real image as its child (`<Picture><img … /></Picture>`). `ratio` is its shape, `4 / 3` by default. A picture never needs a card round it | `div.ui-picture.ui-pattern` + `--ratio` |
| `Alert tone title` | A message that stays on the page | `ui-alert ui-alert--warning` |
| `Empty title text icon solid` | An empty list, with the first action inside. On a picture or a painted pattern give it `solid`: a solid box, so the words can be read | `ui-empty…`, `ui-empty--solid` |
| `Skeleton`, `Spinner`, `Progress value label showValue` | Loading. Leave `value` out of `Progress` while it is not known how far the task is | `ui-skeleton`, `ui-spinner`, `progress.ui-progress` |
| `Meter value min max label showValue warnFrom dangerFrom format` | A reading within a known range: storage used, seats taken, a quota. Not a task under way: that is `Progress` | (React only; plain HTML uses `progress.ui-progress`) |
| `Tabs`, `TabsList variant`, `Tab value`, `TabsPanel value` | Views of one thing; `variant="pills"` for the round style. For pages, use links with `className="ui-tab"` | `ui-tabs…`, `ui-tabs-list--pills` |
| `Count muted` | A count on a tab, a nav item or a bell | `ui-count` |
| `Breadcrumb items` | Where this page sits | `ol.ui-breadcrumb` |
| `Pagination page defaultPage pageCount total pageSize siblings href` / `onPageChange` | Pages of a list. With `href` the pages are real links, which also work before scripts load. In a narrow box it shows only the current page between the first and the last, so the row never wraps | `nav.ui-pagination` |
| `Steps steps current` | Where the person is in a task with a few steps. In a box narrower than 36rem only the current step keeps its name | `ol.ui-steps` > `li.ui-step` + `aria-current="step"`, `data-done` |
| `Toolbar aria-label` with `ToolbarButton`, `ToolbarLink`, `ToolbarInput`, `ToolbarGroup`, `ToolbarSeparator`, `Toggle` | A row of controls above a list, an editor or a canvas. Tab enters it once and the arrow keys move between its items. A menu or select joins through its trigger: `<MenuTrigger render={<ToolbarButton />}>` | `ui-toolbar` |
| `Menubar` with `Menu` + `MenubarTrigger` + `MenuContent` | The menus of an application in one row: File, Edit, View. It draws its own bar (a quiet fill under the menus) | (React only) |
| `NavigationMenu items aria-label link` | A site's main links in a row (in a page's header, use `SiteHeader`, which folds them on a phone), some with a panel of links that opens under them. `items` are `{ label, href }` or `{ label, links: [{ label, href, description?, icon? }] }`. For a public page; inside an app use `Sidebar` and `Nav` | (React only) |
| `Logo name mark src href` | The site's logo. With no `src` it draws one: a mark in the brand colour (the name's first letter, or the icon in `mark`) and the name | `a.ui-logo` > `.ui-logo-mark` + `.ui-logo-name` |
| `SiteHeader brand brandHref items actions link menuTitle sticky`, `SiteMenu title items actions link current` | The header of a public page or site, inside the page's `Container` (see The page): the brand (a plain name is drawn as a `Logo`), the main links (the same `items` as `NavigationMenu`) and one or two `actions` in one line. It floats: at the top of the page it sits on the page, and once the page scrolls it stays as a solid bar (`sticky={false}` leaves it in place). Links to places on the page (`#rooms`) follow the reader: the section in view is marked and the mark slides between links. When its box is narrower than 48rem it folds into a `Burger` that opens a floating menu: the links set large and numbered, rising in one after another, and a picture painted from `menuTitle` (the site's name) with the actions under it. A link to a place on the page closes the menu, then scrolls there. Use it rather than putting `NavigationMenu` in a `Row` yourself. `SiteMenu` is its phone menu alone (the two-line button and the panel it opens): for a bar of your own, put it at the bar's end and show it where the links do not fit. Never build another menu for a phone | `header.ui-site-header` > `.ui-site-header-bar` |
| `TabBar`, `TabBarItem active`, `TabBarLabel` | The main sections at the bottom of a phone screen; it sticks to the bottom of the window, except as the last child of a `Card` or dialog, where it is that box's bottom edge. `TabBar floating`: a small bar that floats over the screen (a dock); the chosen item is ink and shows its `TabBarLabel`, the others only their icon and an `aria-label` | `nav.ui-tabbar` > `a.ui-tabbar-item`; `ui-tabbar--floating`, `span.ui-tabbar-label` |
| `Checklist items` | Rules or steps that tick themselves as they are met: a password's rules, a setup's steps. `items` are `{ label, done }` | `ul.ui-checklist` > `li[data-done]` > `span.ui-checklist-mark` |
| `PickTile picked` | A picture to pick (photos to keep, a cover to use): the picture and a `Checkbox` inside, ringed in ink when picked | `div.ui-pick[data-picked]` > `img` or `.ui-pattern` + `.ui-checkbox` |
| `CommandPalette items` | Search for a page or an action and run it from the keyboard (⌘K). Once, in the layout | (React only) |
| `SortHeader direction onSort` | A column heading that sorts the table; a chosen row is `aria-selected="true"` | `th[aria-sort]` > `button.ui-sort` |
| `List`, `ListItem` | Rows with a line between: settings, people, files. `data-done` on a row that is dealt with (bought, sent) makes it quieter | `ul.ui-list` > `li.ui-list-item` |
| `Collapsible title open defaultOpen onOpenChange findable` | One thing that opens ("Advanced options"). `findable` lets the browser's find-in-page open it | `details.ui-collapsible` > `summary` + `ui-collapsible-content` |
| `Carousel item controls indicators loop defaultPlaying bleed aria-label` | A row to swipe through; each child is one item. `controls` adds previous and next buttons, `indicators` a dot for each page. Inside a card or a dialog it runs to the box's edges by itself (the first item still lines up with the text, and the last keeps the same room); `bleed="2rem"` does the same in a box of your own. Where more slides continue, the row fades into whatever is behind it (a transparency mask, so it works on any background), on the side that has more, and clears at the ends | `ui-carousel` + `--item` |
| `ScrollArea maxHeight aria-label stickToEnd` | A box that scrolls inside the page, with scrollbars drawn to match and a soft fade where there is more. `stickToEnd` follows new content, like a chat | `ui-scroll` + `--max-height` |
| `AspectRatio ratio` | Keeps a shape for an image, video or map | `ui-ratio` + `--ratio` |
| `Prose` | Long text that came as plain HTML: a help page, an article | `ui-prose` |
| `Banner primary` | A message across the top of the page | `ui-banner` |
| `Divider` | A line with a word in the middle: "or" | `ui-divider` |
| `Trend direction` | Up or down next to a number | `ui-trend ui-trend--up` |
| `ChipRemove` | The "×" inside a chip that takes it away | `button.ui-chip-remove` |
| `Timeline aria-label orientation`, `TimelineItem title time dateTime status current` | What happened, in order. `status` (`complete`, `current`, `upcoming`) is for a process with steps, like an order. One tab stop; the arrows move between events | `ol.ui-timeline` > `li.ui-timeline-item` |
| `Waterfall items columns marks value onValueChange aria-label` | Things that start and last, as bars on one time axis: a page's requests, the steps of a job. `items` are `{ value, label, start, duration, children? }` in milliseconds; spans with children open and close | (React only) |
| `DescriptionList items plain` | Facts about one thing, name left and value right, with a hairline between the rows: details, contacts, opening hours. An item's `icon` goes before its name. `plain` drops the lines, for a few short facts in a card | `dl.ui-dl` > `div.ui-dl-row` > `dt` (+ `span.ui-dl-icon`) + `dd`; `ui-dl--plain` |
| `Ring value size label` | A ring that fills up: a share, a score | `ui-ring` + `--value` |
| `Sparkline values area label` | A small line chart next to a number | `svg.ui-sparkline` |
| `ui-split-bar` (class) | One bar split into parts that add up to 100. `data-dim` on the parts not looked at steps them back | children with `--value`, optional `--tone`, `data-dim` |
| `Pre` | A block of code or a command | `pre.ui-pre` |
| `Accordion`, `AccordionItem title` | Questions and answers | `details.ui-accordion-item` > `summary.ui-accordion-trigger` |
| `ui-list`, `ui-list-item` (classes) | Rows with dividers: settings, people, files | |

### On top of the page

These need React (`'use client'` is already in the files). Pass the element that opens them with `render`:

```tsx
<Dialog>
  <DialogTrigger render={<Button />}>Invite</DialogTrigger>
  <DialogContent>
    <DialogHeader>
      <DialogTitle>Invite a person</DialogTitle>
      <DialogDescription>They get an email with a link.</DialogDescription>
    </DialogHeader>
    …
    <DialogFooter>
      <DialogClose render={<Button variant="ghost" />}>Cancel</DialogClose>
      <Button variant="primary">Send invite</Button>
    </DialogFooter>
  </DialogContent>
</Dialog>
```

| Component | Use |
|---|---|
| `Dialog…`, `DialogContent variant="wide" \| "drawer" \| "sheet"`, `DialogClose afterClose` | A task in a window; `drawer` slides in from the right for details, `sheet` rises from the bottom (best on a phone). Everything that opens on top closes with a fade: put what a close button does to the page in `afterClose`, never `onClick`, so it runs once the closing is over (the same on `AlertDialogClose` and `DrawerClose`). Otherwise the page can take the dialog away mid-fade and it just vanishes |
| `Drawer side snapPoints modal`, `DrawerTrigger`, `DrawerContent handle`, `DrawerHeader`, `DrawerTitle`, `DrawerDescription`, `DrawerBody`, `DrawerFooter`, `DrawerClose` | A panel from an edge that the person drags: swipe it away, or rest it at several heights (`snapPoints={[0.5, 0.9]}` with `handle="button"`). `side` is `bottom`, `top`, `left`, `right`. Use it where the panel is moved by hand, above all on a phone; for a plain side panel the dialog's `drawer` is enough |
| `AlertDialog`, `AlertDialogTrigger`, `AlertDialogContent title description`, `AlertDialogClose afterClose` | A question that must be answered: delete, discard |
| `Menu onAction`, `MenuTrigger`, `MenuContent`, `MenuItem value danger shortcut`, `MenuLinkItem`, `MenuGroup` + `MenuLabel`, `MenuSeparator` | Actions on a thing (the "⋯" button of a row). `shortcut="mod+s"` shows the key the way the person's computer writes it; it is a hint, your code handles the key itself with `useShortcut` |
| `MenuSub`, `MenuSubTrigger`, `MenuSubContent` | A menu inside a menu: "Export" with its formats |
| `MenuCheckboxItem checked onCheckedChange`, `MenuRadioGroup value` + `MenuRadioItem value` | Menu rows that tick: "Show weekends", "Sort by" |
| `HoverCard content` | A small card when a link is hovered or focused: a person, a record. Never the only way to the information |
| `ContextMenu`, `ContextMenuTrigger`, `ContextMenuContent` | The same menu on right-click or long press, with the same `MenuItem`s. The trigger takes focus, and the menu key or Shift+F10 opens the menu. Always offer the actions another way too |
| `Popover`, `PopoverTrigger`, `PopoverContent`, `PopoverTitle`, `PopoverDescription` | A small panel next to its button. It spaces what is put in it, like a dialog: put rows, fields and buttons straight inside |
| `Tooltip content delay` | The name of an icon button. Never the only place for information: phones have no hover. It opens after the pointer rests 600ms; `delay={150}` where people sweep across many things to read their names, like a grid of icons |
| `Toaster`, `toast.success({ title, description })`, `toast.info(…)`, `toast.warning(…)`, `toast.error(…)`, `toast.show(…)` | A message that pops up and leaves by itself: "Saved". Its kind shows as a small round mark in front (none for `show`); the words stay in the text colour. It has no close button: it goes after five seconds, or is swiped away, and a thin ring round its mark runs down with the time left (it waits while the pointer or focus is on the stack, or the window is in the background). Anything the person must not miss is an `Alert`, never a toast that stays. `ToastMark type` draws the same mark elsewhere. `Toaster` goes once in the root layout; it also starts smooth resizing for the whole page (`startSmoothSizes`): cards and dialogs grow and shrink in the kit's movement time when their content changes, and a box of your own joins with `data-ui-smooth`. Add `action: { label: 'Undo', onClick }` for a button on it |
| `Notifications`, `Notification title time unread media actions` | Things that happened and stay until read: a list in a `Popover` under a bell (an icon `Button` with a `Count` inside), or on a page of its own. Class `ui-notifications` > `ui-notification` + `data-unread`; panel `ui-popup ui-notifications-panel` |

Without React: `<dialog class="ui-dialog" closedby="any">` with `showModal()` (`closedby="any"` closes it on a click outside and on Escape; the React dialogs do this already), and `<div popover class="ui-popup">` with `ui-menu-item` rows, both built into the browser. A tooltip without React is one attribute: `<button data-tip="Delete">` (add `data-tip-side="bottom"` near the top of the page).

### Helpers

Small things that come with the kit, imported from the same folder:

| Helper | Use |
|---|---|
| `UIProvider locale messages`, `useMessages()` | The language of the kit's own words, and of its dates and numbers, set once in the root layout (see Every language, every direction, every eye) |
| `Kbd` | A key or a shortcut written in a sentence: `<Kbd>⌘K</Kbd>` |
| `Label` | A label over a group of controls that is not one field (`Field` labels a single field) |
| `Icon icon size solid label` | A `lucide-react` icon in the theme's size and weight: `<Icon icon={Search} />`; give `label` when the icon alone says something |
| `ToastMark type` | The round mark a toast shows (success, info, warning, error, loading), for a message shaped like a toast that is not one |
| `useShortcut('mod+k', run)`, `formatShortcut('mod+k')` | A keyboard shortcut for the whole app (`mod` is Cmd on a Mac and Ctrl elsewhere), and the same shortcut written the way the person's computer shows it |
| `useAsyncOptions(load, { debounce })` | Options loaded from the server while the person types, for `Autocomplete` and `Combobox`: it waits for a pause, drops answers that arrive too late and reports loading and errors. Pass its `items` and `status`, with `filter={false}` |
| `fuzzyScore`, `matchSegments` | Ranking a list against what was typed, and marking the part that matched |
| `createPreference`, `createLocalStorage`, `Preferences`, `usePreference` | A choice the person makes once and keeps in their browser: list or grid view, an open sidebar. Not for settings that belong to the account or the site |
| `ColorSchemeSwitch`, `ColorSchemeProvider` | Lets the person choose light or dark for themselves, on their own device. The theme's `mode` stays the default. With it, wrap the page in `<ColorSchemeProvider>` at the top of `<body>` in the root layout and add `suppressHydrationWarning` to `<html>`: the saved choice is then applied before the page is drawn |
| `announce('3 results')` | Says a message to screen readers without showing it |

## Building what the kit does not have

A screen often needs one piece nobody has made: a seat map, a stepper, a time-slot grid, an emoji picker. Do not write it from scratch and do not add another component library. UI SDK, already installed with the kit, is a library of tested behaviours made for exactly this: an AI puts them together into a new component, and the keyboard, focus, screen readers, right-to-left text and AI assistants work from the start.

How, in this order:

1. **Look in the kit first**, then among UI SDK's own unstyled components (`node_modules/@ui-sdk/react/docs/llms.txt` lists them all). The kit wraps every one of them, so this mostly matters for an option the kit's wrapper does not pass on: then use the SDK's parts directly, with the kit's classes.
2. **Read the guide for building one**: `node_modules/@ui-sdk/core/skills/ui-sdk/SKILL.md` and its `references/create-component.md`. It matches the installed version.
3. **Pick the behaviours.** `node_modules/@ui-sdk/react/docs/core.md` is long: search it by heading. Its "All Behaviors" chapter lists them by topic: focus and keys (`createRovingFocus`, `createGridFocus`, `createTypeahead`), selection (`createSelection`, `createLasso`, `createCellRange`), drag and drop (`createReorder`, `createTransfer`, `createTreeReorder`), moving and resizing (`createMove`, `createResize`, `createSpans`, `createSwipeActions`), lists (`createListbox`, `createVirtualizer` for very long ones, `createInlineEdit`, `createStickToBottom`), popups (`createPopup`), a canvas that pans and zooms (`createViewport`, `createConnect`), undo (`createUndoStack`).
4. **Define it once** with `definePrimitive` (its state, what it can do, its parts), and turn it into React parts with `createParts` from `@ui-sdk/react/primitive`.
5. **Report every change through `createChange`**, so the screen that uses the component can save it or refuse it, and it is recorded with who made it.
6. **End it with the `agent` key**: `agent: { actions: ['move'] }` lists what an assistant may do with it. Without it an assistant can only use methods named like `setValue` or `toggle`.
7. **Style it with the system**: your own class names, only `var(--ui-…)` tokens and the kit's classes, a transition on everything that changes, corners from `--ui-radius…`. State comes from the attributes the parts set (`data-selected`, `data-dragging`), never from inline styles.
8. **Test it** with `@ui-sdk/core/testing` (the guide's `references/testing.md`): the keys, where focus goes, what a screen reader is told. Then try it by hand with the keyboard only.

Two components in the kit are made this way and are the pattern to follow: `components/ui/sortable.tsx` (a list put in order by dragging, from `createReorder` and `createRovingFocus`) and `components/ui/board.tsx` (cards moved between columns, from `createTransfer`). Put your own next to the `ui` folder, not inside it: the folder is replaced when the kit is updated.

Only for what UI SDK has no behaviour for (a rich text editor, a map, a full charting library), use a well-known open-source library and style it with the tokens, so it follows the theme. For charts beyond `Bars`, `Ring` and `Sparkline`, draw SVG with the tokens or use a small open-source chart library, with series in `--ui-primary` and tones.

## Icons

Supply UI uses **Lucide** (lucide.dev, ISC licence): open-source line icons. Use it for every icon, and no other set.

**React**: any icon from `lucide-react`, by name.

```tsx
import { Plus, Search, Trash2 } from 'lucide-react';
import { Button, Icon } from '@/components/ui';

<Button variant="primary"><Plus />New booking</Button>      // inside a button, menu item or nav item: just the icon
<Button icon aria-label="Search"><Search /></Button>        // an icon alone needs an aria-label on its button
<Icon icon={Trash2} size="lg" />                             // on its own: sm, md (follows the text), lg, xl
<Icon icon={Star} solid label="Favourite" />                 // filled "on" state; label when it carries meaning alone
```

**Without React**: one file with the most used icons. Save it next to your other static files and point at an icon by name.

```bash
curl -fsSL https://www.supply.family/ui/icons.svg -o public/icons.svg
```

```html
<button class="ui-btn ui-btn--primary"><svg class="ui-icon" aria-hidden="true"><use href="/icons.svg#plus" /></svg>New booking</button>
```

The names in the file are listed at `https://www.supply.family/ui/icons.json`. For any other Lucide icon, copy its SVG from lucide.dev and give it `class="ui-icon"`.

Rules:

- An icon is as heavy as the text beside it. Icons take the colour of the text around them and their line weight from it: the theme's `--ui-icon-stroke` is the weight beside regular text, and every kit rule that sets a font weight also sets `--ui-icon-weight` (`var(--ui-icon-medium)`, `var(--ui-icon-bold)`), so an icon in a button, a tab or a title follows its words. When your own CSS sets a `font-weight` on something that can hold an icon, set `--ui-icon-weight` with it the same way (the style check refuses one without the other). Never set a colour, `stroke-width` or pixel size on an icon.
- Sizes: default (follows the text), `ui-icon--sm`, `ui-icon--lg`, `ui-icon--xl`. `ui-icon--solid` fills it in. `ui-icon-tile` puts an icon in a soft square for feature lists and empty states.
- An icon next to text is decoration (`aria-hidden`, which `Icon` and the sprite markup above already set). An icon alone needs a name: `aria-label` on its button, or `label` on `Icon`.
- Use the same icon for the same thing everywhere (`Trash2` for delete, `Pencil` for edit, `Plus` for add, `X` for close, `Ellipsis` for more).
- Do not use emoji as icons, and do not mix in filled or two-tone sets.

## Patterns

A pattern is a painted picture the kit makes by itself, from a word (the **seed**) and the theme's colours. Use it wherever the design wants an image and there is no real one:

- the cover of a card (a project, a product, a document, a plan): `CardCover`,
- a picture on the page, in a carousel or beside text: `Picture`, never a card made only to frame it,
- a person or a thing without a photo (`PatternAvatar`),
- the top of an empty page, a sign-in screen or a banner.

Words never sit straight on a pattern: its colours change under every letter. On a pattern they go in a solid box: a `Card`, the panel of a `Cover`, an `Empty` with `solid`. The edge check (rule 13) lists words left on a painting.

The same seed always paints the same picture, so use something stable: the record's name or id. Never a random number, or the picture changes on every visit.

**React**

```tsx
import { Card, CardBody, CardCover, Pattern, PatternAvatar, Picture } from '@/components/ui';

<Card>
  <CardCover seed={project.name} />          // 16:9 by default; style={{ '--ratio': '4 / 3' }} to change
  <CardBody>…</CardBody>
</Card>

<Picture seed={place.name} />                // a picture on its own, rounded; ratio="16 / 9" to change
<Pattern seed="welcome" style={{ minHeight: 240 }} />   // any block: give it a size
<PatternAvatar name={person.name} />
```

**Without React**: one small script, then mark the elements.

```bash
curl -fsSL https://www.supply.family/ui/supply-pattern.js -o public/supply-pattern.js
```

```html
<div class="ui-card-cover ui-pattern" data-pattern="Project name"></div>
<div class="ui-picture ui-pattern" data-pattern="Morning swim"></div>
<span class="ui-avatar ui-pattern" data-pattern="Jamie Lee" data-pattern-palette="auto" data-pattern-look="0" role="img" aria-label="Jamie Lee"></span>
<script src="/supply-pattern.js" defer></script>
```

Options: `palette` is `theme` (default: the theme's colours, repainted when the theme changes), `auto` (one of eleven house palettes, picked by the seed: use it for people, so they differ from each other) or a number 0–10; in React and in `SupplyPattern.watch` it can also be your own list of hex colours, up to six paints and then the paper. `look` is `0` (soft pools of paint) or `1` (fine veins); left out, the seed picks.

Rules:

- A real image always wins. When the record has a photo or an upload, show that (`<CardCover><img … /></CardCover>` shows the image in the same frame).
- Never put text straight on a pattern. Text goes in a card, a chip or a badge laid over it.
- A pattern is decoration: it carries no information, and needs no description for screen readers (an avatar keeps its `aria-label`).
- Do not use stock photos, AI-generated images or illustrations from other sources to fill space. Use a pattern.
- It needs WebGL, which every current browser has; without it the element shows a soft gradient in the theme's colours.

For "not yet" and "forecast" (a future bar in a chart, a placeholder block) use the hatch: class `ui-hatch`.

## Tailwind (optional)

Supply UI does not need Tailwind. If the project uses Tailwind v4 anyway, also import `supply-ui-tailwind.css` after Tailwind: it maps Tailwind's and shadcn's colour names (`bg-background`, `text-muted-foreground`, `bg-primary`, `rounded-lg`…) to the tokens, so utilities and any shadcn component follow the theme too. Never use Tailwind's fixed palette (`bg-blue-500`, `text-gray-600`): it ignores the theme.

## Every language, every direction, every eye

**Your language.** Every word the kit writes by itself (the name of a close button, "Nothing found", "Previous page") comes from one `messages` object. Set it once, with the locale for dates and numbers, in the root layout:

```tsx
import { UIProvider } from '@/components/ui';

<UIProvider locale="de" messages={{ nextPage: 'Nächste Seite', previousPage: 'Vorherige Seite', nothingFound: 'Nichts gefunden.' }}>
  {children}
</UIProvider>
```

Words left out stay English; `messages` in the kit lists them all. A word given to a component directly (`aria-label`, `placeholder`, `empty`) always wins. Without `locale`, calendars and date pickers follow the page's `<html lang>`. A component of your own that needs one of the same words reads it with `useMessages()`.

**Right to left.** Set `dir="rtl"` (and the language) on `<html>`: the kit turns round by itself. Its sides are logical (start and end), its arrows that point along the line turn, a switch's knob moves the other way, and codes, amounts and dates (`ui-mono`, `ui-num`, `code`) still read left to right. In your own CSS write `margin-inline-start`, `padding-inline-end`, `inset-inline-start` and `text-align: start`, never left and right; give an icon of your own that points along the line `className="ui-icon--flip"`.

**High contrast.** In Windows' high-contrast mode (forced colours) the system repaints every fill and drops every shadow; the kit gives its fields, cards and controls an edge, shows what is chosen in the system's highlight, and draws focus as an outline. When a person asks for more contrast (`prefers-contrast: more`), lines get stronger, quiet text comes closer to the text colour, and fields show their edge at rest. Do not show something only with a fill or a shadow in your own CSS: give it an edge too.

## Check before you ship

- Try every screen with two very different theme codes (a light one and a dark one, small and large corners), in every theme `themeStyles` lists: everything stays readable, nothing keeps an old colour, and no screen keeps a shadow or border of its own.
- Open every screen at 320, 375 and 768 px wide and run the narrow check of rule 10: it returns an empty list. Then drag the window from wide down to 240 px: the page never scrolls sideways on the way.
- Run the checks of rules 13 and 15 on every screen: both return an empty list. Count the cards on a public page: most of its sections should have none.
- In the browser console of a screen, look at the assistant's list once (`getAgent().snapshot()`, exposed from a client component while testing): every control a person can use is in it, each has a name a person would recognise, and nothing that deletes, pays or sends is without `data-agent-confirm`.
- Go through every screen with the keyboard only: every Tab stop can be seen, shows that it has focus and has a name; menus, selects and dialogs open with Enter, move with the arrows, close with Escape and give focus back. A box that scrolls and holds no control of its own (a long command, a table that scrolls) takes `tabIndex={0}` and an `aria-label`, so the keys can scroll it.
- Use every component you built yourself with the keyboard only, and check it is in that list with the actions it should offer.
- Search your own CSS and inline styles for `#`, `rgb(` and `px` font sizes: there should be none outside `components/ui/`.
