---
name: xerobi-design
description: Xerobi product design guidance. Use when designing, implementing or reviewing interfaces built with @xerobi/ui: tokens, typography, colour, forms, dialogs, responsive layout, accessibility and tests.
---

# Xerobi design

Apply these rules when designing, implementing or reviewing Xerobi product interfaces. Follow the examples marked Good and avoid the ones marked Avoid. When a rule conflicts with a user's explicit request, say so and follow the request.

Use `xerobi-ui doc <component>` for a component's props and variants, and `xerobi-ui ai` for the full usage guide.

## Foundations

### `token-values` Take every value from the tokens

Colour, spacing, radius, shadow, z-index and duration come from `@xerobi/tokens` through Tailwind utilities or CSS variables. No hex values, no numeric z-index, no arbitrary radii or durations.

**Good**

```tsx
<div className="rounded-md bg-card text-text-primary z-modal" />
```

**Avoid**

```tsx
<div className="rounded-[7px] bg-[#1a1a1a] text-[#fff] z-[1300]" />
```

### `no-default-palette` Never use Tailwind's default colour ramps

`bg-blue-500`, `text-gray-700` and similar bypass the brand and break in dark mode. Use the semantic names: `primary`, `secondary`, `info`, `success`, `warning`, `error`, `grey`, and the text and background roles.

**Good**

```tsx
<span className="text-text-secondary">Last synced 2 minutes ago</span>
```

**Avoid**

```tsx
<span className="text-gray-500">Last synced 2 minutes ago</span>
```

### `brand-is-primary` Rebrand through the primary colour only

A product changes `primary`; shades and contrast text are derived. Never hard-code a product colour in a component.

**Good**

```tsx
<ThemeProvider brandColor="#7635DC">{children}</ThemeProvider>
```

**Avoid**

```tsx
<Button className="bg-[#7635DC] hover:bg-[#5e2bb0]">Save</Button>
```

### `status-colour-meaning` Reserve status colours for status

`success`, `warning`, `error` and `info` carry meaning. Do not use them for decoration, categories or emphasis. Use `primary` for emphasis and `grey` for neutral.

**Good**

```tsx
<Badge variant="soft" color="success">Active</Badge>
```

**Avoid**

```tsx
<Badge variant="soft" color="success">Premium plan</Badge>
```

### `soft-for-light-status` Use soft styles for info, success and warning

White text on filled `info` and `success` is below 3:1 contrast. Use the soft variant, or an outlined one, for these colours. Filled is fine for `primary` and `secondary`.

**Good**

```tsx
<Alert variant="success">Changes saved.</Alert>
<Button variant="soft" color="info">Learn more</Button>
```

**Avoid**

```tsx
<Button color="info">Learn more</Button>
```

## Typography

### `type-roles` Use type roles, not font sizes

Roles are `text-h1` to `text-h6`, `text-subtitle1`, `text-subtitle2`, `text-body1`, `text-body2`, `text-caption`, `text-overline`, `text-button`. Use `text-body2` (14px) for interface text and `text-body1` for reading text. Do not set `text-[15px]` or stack `text-sm font-semibold` by hand.

**Good**

```tsx
<h2 className="text-h6">API tokens</h2>
<p className="text-body2 text-text-secondary">Production tokens expire in 30 days.</p>
```

**Avoid**

```tsx
<h2 className="text-[17px] font-semibold">API tokens</h2>
<p className="text-sm text-gray-500">Production tokens expire in 30 days.</p>
```

### `sentence-case` Write headings and buttons in sentence case

Capitalise the first word and proper nouns only. Never uppercase with CSS except `overline`.

**Good**

```tsx
<Button>Create project</Button>
```

**Avoid**

```tsx
<Button>CREATE PROJECT</Button>
```

### `button-labels` Label buttons with a verb and the object

Say what happens. Avoid "OK", "Submit" and "Yes".

**Good**

```tsx
<Button>Delete project</Button>
<Button variant="outline">Cancel</Button>
```

**Avoid**

```tsx
<Button>OK</Button>
```

### `inline-code` Keep inline code one step smaller

Inline monospaced text sits at `text-caption` size inside body text so it does not look heavier than its surroundings.

**Good**

```tsx
<p className="text-body2">Run <code className="text-caption">xerobi-ui init</code> first.</p>
```

**Avoid**

```tsx
<p className="text-body2">Run <code className="text-body1">xerobi-ui init</code> first.</p>
```

## Actions

### `one-primary-action` One primary action per region

A page region, dialog or card has one filled primary button. Secondary actions use `outline` or `ghost`. Destructive actions use `color="error"`.

**Good**

```tsx
<DialogFooter>
  <Button variant="outline">Cancel</Button>
  <Button>Save changes</Button>
</DialogFooter>
```

**Avoid**

```tsx
<DialogFooter>
  <Button>Cancel</Button>
  <Button>Save changes</Button>
</DialogFooter>
```

### `loading-state` Show progress on the control that was activated

Use the button's `loading` prop. It disables the control and shows a spinner without changing its width. Do not swap the label for "Loading...".

**Good**

```tsx
<Button loading={isPending}>Save changes</Button>
```

**Avoid**

```tsx
<Button disabled={isPending}>{isPending ? "Loading..." : "Save changes"}</Button>
```

### `confirm-destructive` Confirm destructive actions in an alert dialog

Deleting, revoking or anything that cannot be undone uses `AlertDialog`, names the object being affected, and the confirm button uses the error colour. Do not use a plain `Dialog`.

**Good**

```tsx
<AlertDialog>
  <AlertDialogTrigger render={<Button variant="outline" color="error">Delete project</Button>} />
  <AlertDialogContent>
    <AlertDialogHeader>
      <AlertDialogTitle>Delete "Billing site"?</AlertDialogTitle>
      <AlertDialogDescription>Its deployments and domains are removed. This cannot be undone.</AlertDialogDescription>
    </AlertDialogHeader>
    <AlertDialogFooter>
      <AlertDialogCancel>Cancel</AlertDialogCancel>
      <AlertDialogAction>Delete project</AlertDialogAction>
    </AlertDialogFooter>
  </AlertDialogContent>
</AlertDialog>
```

### `icon-button-name` Give icon-only buttons an accessible name

Use `aria-label`, and a tooltip when the icon is not self-evident.

**Good**

```tsx
<Button size="icon" variant="ghost" aria-label="Open settings"><SettingsIcon /></Button>
```

**Avoid**

```tsx
<Button size="icon" variant="ghost"><SettingsIcon /></Button>
```

## Feedback and states

### `design-every-state` Design loading, empty, error and success

Every list, table and form has all four. Use `Skeleton` for loading, `EmptyContent` for empty, `Alert` for persistent errors and `toast` (from `snackbar`) for transient confirmation.

**Good**

```tsx
{items.length === 0 ? (
  <EmptyContent title="No projects yet" description="Create a project to get started." action={<Button>Create project</Button>} />
) : (
  <ProjectList items={items} />
)}
```

**Avoid**

```tsx
{items.map((item) => <ProjectRow key={item.id} {...item} />)}
```

### `error-messages` Say what failed and how to fix it

Inline, next to the field, in plain language. Never "Invalid input".

**Good**

```tsx
<HelperText errorMessage="Use 3 to 32 characters: letters, numbers and hyphens." />
```

**Avoid**

```tsx
<HelperText errorMessage="Invalid input" />
```

### `toast-vs-alert` Transient feedback is a toast, persistent feedback is an alert

A toast confirms something that already happened and goes away. An alert stays until the condition is resolved.

**Good**

```tsx
toast.success("Project created")
<Alert variant="warning">Your plan expires in 3 days.</Alert>
```

**Avoid**

```tsx
toast.warning("Your plan expires in 3 days.")
```

## Forms

### `forms-on-tanstack` Build forms with the form block

Use `useForm`, `Form` and the `Field*` components. They wire validation, error text and accessibility. Do not combine raw inputs with ad hoc state.

**Good**

```tsx
const form = useForm({ defaultValues: { name: "" }, onSubmit: save })
<Form form={form}>
  <Field.Text name="name" label="Project name" />
  <Button type="submit" loading={form.state.isSubmitting}>Create project</Button>
</Form>
```

### `labels-always` Every field has a visible label

Placeholders are examples, not labels. Mark optional fields, not required ones.

**Good**

```tsx
<Field.Text name="domain" label="Custom domain" helperText="Optional" placeholder="app.example.com" />
```

**Avoid**

```tsx
<Input placeholder="Custom domain" />
```

### `input-size-mobile` Keep inputs at 16px below the sm breakpoint

The library does this for you. Do not override the input font size, or iOS zooms the page on focus.

## Layout

### `breakpoints` Use Xerobi breakpoints

`sm` 600, `md` 900, `lg` 1200, `xl` 1536. They differ from Tailwind's defaults and there is no `2xl`. Design at 360px first.

**Good**

```tsx
<div className="grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3" />
```

### `layer-tokens` Use named layers

`z-local`, `z-appBar`, `z-drawer`, `z-modal`, `z-snackbar`, `z-tooltip`. Do not invent a number to win a stacking fight; fix the stacking context.

**Good**

```tsx
<header className="sticky top-0 z-appBar" />
```

**Avoid**

```tsx
<header className="sticky top-0 z-[9999]" />
```

### `radius-scale` Use the radius scale

`rounded-md` (8px) is the default for controls and cards. Nested elements use a smaller step than their container so corners stay concentric.

**Good**

```tsx
<Card className="rounded-xl p-2"><div className="rounded-md" /></Card>
```

## Interaction and accessibility

### `focus-visible` Never remove the focus indicator

If you remove the default outline, add `focus-visible:ring-3 focus-visible:ring-ring`. Programmatic-focus containers such as dialog popups are the only exception.

**Good**

```tsx
<div tabIndex={0} className="outline-none focus-visible:ring-3 focus-visible:ring-ring" />
```

**Avoid**

```tsx
<div tabIndex={0} className="outline-none" />
```

### `keyboard-parity` Everything reachable by pointer is reachable by keyboard

Use Base UI based components for menus, dialogs, tabs and selects. Do not build interactive widgets from `div` and `onClick`.

**Good**

```tsx
<Button onClick={open}>Open</Button>
```

**Avoid**

```tsx
<div onClick={open}>Open</div>
```

### `motion-tokens` Use motion tokens and respect reduced motion

Durations are `duration-150`, `duration-200`, `duration-300`. The global stylesheet turns motion off for `prefers-reduced-motion`, so do not add JavaScript animation that ignores it.

**Good**

```tsx
<div className="transition-opacity duration-200 ease-out" />
```

**Avoid**

```tsx
<div className="transition-all duration-[1700ms]" />
```

### `target-size` Keep targets at least 24px

Controls are 24, 30, 36 or 48px high. Icon buttons below `size="icon-xs"` are not allowed.

### `colour-not-alone` Do not use colour as the only signal

Pair status colours with an icon or text. A red border alone does not tell a colour-blind user a field failed.

**Good**

```tsx
<Alert variant="error"><AlertTitle>Payment failed</AlertTitle></Alert>
```

## Dialogs and overlays

### `dialog-always-mounted` Control dialogs with `open`, do not conditionally render them

Conditional rendering skips exit animation and loses focus restoration.

**Good**

```tsx
<Dialog open={open} onOpenChange={setOpen}>...</Dialog>
```

**Avoid**

```tsx
{open && <Dialog open>...</Dialog>}
```

### `tooltip-content` Tooltips add a name, not essential information

Anything the user needs to complete a task belongs in the interface, not a tooltip. Touch users never see tooltips.

## Testing

### `test-roles` Query by role and accessible name

**Good**

```tsx
screen.getByRole("button", { name: "Create project" })
```

**Avoid**

```tsx
container.querySelector(".bg-primary")
```

### `audit-before-merge` Run the design audit

`bun run audit:design` must report zero errors. New exceptions go in `scripts/audit-allowlist.json` with a reason.
