Hive design tokens
The Hive design system names its values instead of repeating them. Every token lives in one
file, apiome-ui/src/app/globals.css, and Studio uses the same stylesheet, so a token means the
same thing in the web app and in Studio. The design language behind the tokens is
docs/mockups/DESIGN.md. Use the design-system gallery to see each one in
place.
Design tokens
| Family | Tokens | Spent through |
|---|---|---|
| Colour | --color-* (surfaces, ink, lines, accents, status) | bg-surface, text-fg, border-border … |
| Type | --text-*, --font-sans, --font-mono | text-sm, font-mono … |
| Radius and elevation | --radius-*, --shadow-* | rounded-md, shadow-lg … |
| Motion | --dur-*, --ease-* | transition, duration-* |
| Spacing | --space-1 … --space-6, --space-8, --space-10, --space-12 | var(--space-4) in a stylesheet; p-4, gap-4 … |
| Density and layout | --control-h, --control-h-sm, --control-h-lg, --page-pad, --rail-w … | h-control, p-page, the size prop of controls (see below) … |
| Stacking | --z-* | z-chrome, z-modal … (see below) |
| Dialog frame | --dialog-steps-block-size | <DialogContent steps> (see below) |
| Form frame | --form-frame-section-gap, --form-frame-field-gap, --form-frame-max-inline-size | <FormFrame> and <FormSection> (see below) |
Spacing
Spacing is a 4 px grid in rem, so it grows with the Font size preference:
| Step | Value | Step | Value |
|---|---|---|---|
--space-1 | 4 px | --space-6 | 24 px (20 px at Compact density) |
--space-2 | 8 px | --space-8 | 32 px (24 px at Compact density) |
--space-3 | 12 px | --space-10 | 40 px |
--space-4 | 16 px | --space-12 | 48 px |
--space-5 | 20 px |
There is no --space-7, --space-9 or --space-11. A stylesheet that names one gets no
value, and a unit test fails.
Until SUX-1.3 (apiome#6750), a wrapper from the Radix Themes package sat around the whole app
and declared its own --space-* values, so every page used 24, 32 and 48 px where this table
says 20, 24 and 32 px. The Compact density setting also left spacing unchanged. The wrapper
is gone, and pages now use the values above.
Stacking (z-index)
Which element paints over which is decided by one scale of ten named steps. Nothing in the product writes a z-index number; it names a step. SUX-1.1 (apiome#6748) introduced the scale.
| Step | Value | Utility | Used for |
|---|---|---|---|
--z-base | 0 | z-base | The page's own content |
--z-raised | 10 | z-raised | One item lifted over its neighbours: a card's buttons over its link, a table's header row |
--z-sticky | 100 | z-sticky | Sticky page headers, save bars, Studio's project and version toolbar |
--z-chrome | 200 | z-chrome | Global headers and the navigation rail |
--z-floating | 300 | z-floating | Canvas toolbars, docked panels, notices that float over the chrome |
--z-overlay | 1000 | z-overlay | The dimmed backdrop behind a dialog or drawer |
--z-modal | 1010 | z-modal | Dialogs, drawers and the command palette |
--z-popover | 1020 | z-popover | Selects, menus and tooltips, including those opened inside a dialog |
--z-toast | 1030 | z-toast | Toasts |
--z-alert | 1040 | z-alert | Confirm and alert dialogs, backdrop and surface |
alert 1040 ─ toast 1030 ─ popover 1020 ─ modal 1010 ─ overlay 1000
───────────────────────────────────────────────────────────────────
floating 300 ─ chrome 200 ─ sticky 100 ─ raised 10 ─ base 0
The two rows never mix. Every page step is below every overlay step, so opening a dialog or drawer dims the whole screen, global header included. A popover is above a dialog, so a select opened inside a dialog, or inside a dialog opened from a drawer, shows in full above both.
In a component, use the utility: className="fixed inset-0 z-overlay". Passing a different
z-* class to a Hive primitive replaces its step, because cn() treats the step utilities and
Tailwind's own z-* as the same property.
In a stylesheet, use the token: z-index: var(--z-sticky);. For "one step behind",
write calc(var(--z-base) - 1).
From script, for an inline style or a third-party component, use zLayer('toast') from
apiome-ui/lib/zLayers.ts. It returns var(--z-toast). That file lists the steps in order,
and a unit test fails if it and globals.css disagree.
Inside an element that already stacks (anything with its own z-index), a step only orders that element's children. A menu inside the header can never rise above a dialog, however high its step.
Control sizes
Buttons, text inputs, selects, text areas and segmented switches come in the same three sizes. Each size uses one height token, so controls of the same size placed side by side are the same height and their text lines up. The heights change with the Density and Font size preferences. SUX-1.2 (apiome#6749) added the small and large sizes to inputs, selects and text areas.
| Size | Height token | Height (Comfortable) | Height (Compact) | Padding | Text | Corner radius |
|---|---|---|---|---|---|---|
| Small | --control-h-sm | 30 px | 26 px | 10 px | 12 px | rounded-sm |
| Medium (the default) | --control-h | 36 px | 32 px | 12 px | 14 px | rounded-md |
| Large | --control-h-lg | 42 px | 38 px | 16 px | 16 px | rounded-md |
Each control names the sizes in its own way:
| Control | Small | Medium | Large |
|---|---|---|---|
Button | size="sm" | no size, or size="default" | size="lg" |
Input, SelectTrigger, Textarea | size="sm" | no size, or size="md" | size="lg" |
Segmented | size="sm" | no size, or size="default" | size="lg" |
FormField | size="sm" | no size, or size="md" | size="lg" |
- A control with no
sizeis medium. Existing screens did not change. - A
FormFieldpasses its size to the input, select or text area inside it, even one inside a wrapper. Its label is 12 px at the small size. Asizeset on the control itself wins. - A text area keeps its minimum height of six lines and grows as you type. Its size changes only its padding, text and corner radius.
- A segmented switch is as tall as a button of the same size, including its track. Before SUX-1.2, the medium one was 34 px next to a 36 px button.
Inputusessizefor its height. The HTMLsizeattribute, a width in characters, is not available. Set the width with a class such asw-40.


/design-systemForms
FormFrame is the container for a whole form, on a page or in a dialog. It sets the spacing
and the place of the buttons, so two forms of the same kind look the same and are the same
width.
<FormFrame
width="narrow"
header={<h2>Project settings</h2>}
submitLabel="Save project"
onSubmit={save}
dirty={dirty}
error={saveError}
secondaryActions={<Button variant="ghost" onClick={cancel}>Cancel</Button>}
>
<FormSection title="Basics" description="What the project is called.">
<FormField label="Project name" htmlFor="name">
<Input id="name" />
</FormField>
</FormSection>
<FormSection title="Access">{/* more FormFields */}</FormSection>
</FormFrame>
| Part | What it does |
|---|---|
header | The title. In a dialog, pass a DialogHeader. |
| Body (the children) | One or more FormSections, 24 px apart. This part scrolls. |
| Footer | Sticks to the bottom. On the left: Unsaved changes when dirty is set, and error as an alert. On the right: secondaryActions, then the primary button (submitLabel). |
width | narrow (560 px), default (720 px) or wide (960 px), as a maximum. |
- The spacing rule. A
FormSectionhas a title, an optional description and its fields, 16 px apart.FormFieldis the only way to pair a label with its control, with 6 px between them. The gaps are fixed: compact density does not shrink them. - On a page the page scrolls and the footer stays at the bottom of the window. In a
dialog (
<DialogContent><FormFrame …/></DialogContent>) the dialog's body scrolls between its header and footer. - Keyboard. Enter in a single-line field submits the form; in a text area it adds a
line. ⌘S (macOS) or Ctrl+S anywhere in the form also submits, instead of the browser's
Save page. Neither submits while the primary button is disabled (
submitDisabled) or saving (submitting). A disabled primary button shows why as its tooltip: pass the reason assubmitDisabledReason. - Secondary buttons never submit. A button in
secondaryActionswith notypebecomestype="button", so Enter cannot press Cancel by mistake. FormFrameis opt-in. No screen uses it yet; existing forms look the same as before.


/design-systemUnsaved changes
useUnsavedChangesGuard (in @/app/hooks/useUnsavedChangesGuard) asks before a dirty form is
left. Pass the form's dirty flag and, when the form can save, onSave; render the dialog it
returns once, and pass its dirty to FormFrame so the footer and the guard always agree.
const guard = useUnsavedChangesGuard({ dirty, onSave: save, onDiscard: reset });
return (
<>
<FormFrame dirty={guard.dirty} onSubmit={save}>{/* sections */}</FormFrame>
{guard.dialog}
</>
);
While dirty is… | What happens |
|---|---|
false | Nothing. A clean form never asks. |
true, the tab is closed or reloaded | The browser asks to confirm (its own wording). |
true, a link to another page in the app is clicked, or Back is pressed | A dialog asks Leave without saving? with Save, Discard and Cancel. |
- Save runs
onSave, then leaves. IfonSavereturnsfalseor throws, the page stays so its own error is visible. WithoutonSave, the dialog offers only Discard and Cancel. - Discard runs
onDiscard, then leaves. Cancel (or Esc) stays on the page. - Links that open a new tab or window, download a file, go to another site or only jump to a
#sectionare not stopped. Adddata-unsaved-guard="ignore"to let one other link through. - A move the screen makes itself, such as
router.pushfrom a button, cannot be seen from outside: wrap it inguard.confirmLeave(() => router.push(href)). useUnsavedChangesPrompt(dirty)is still there for a screen that wants only the browser's tab-close prompt. The gallery's Forms page-form uses the full guard.
Split pane
SplitPane puts two or three panes side by side with a drag handle between neighbours. Use it
for a form beside a preview, or a tree, a canvas and an inspector.
<SplitPane
aria-label="Theme editor"
storageKey="slate-theme"
panes={[
{ id: 'form', label: 'Form', defaultSize: 360, minSize: 280, maxSize: 520, collapsible: true },
{ id: 'preview', label: 'Preview' },
]}
>
<ThemeForm />
<ThemePreview />
</SplitPane>


/design-system- One flexible pane. Exactly one pane has no
defaultSizeand takes the width that is left. Every other pane has a width in px, kept betweenminSize(default 120) andmaxSize(default 960). Each handle resizes the fixed pane next to it. - Keyboard. A handle is a
role="separator"that takes focus. Press ← or → to move it 16 px, with Shift 64 px. Home goes to the minimum, End to the maximum. Enter collapses or restores acollapsiblepane. Double-click a handle to go back to the default width. - Mouse. Drag a handle. Dragging a collapsible pane below half its minimum collapses it. While you drag, iframes stop taking the pointer, so you can drag across a preview.
- Persisted widths. With
storageKey, the widths and collapsed panes are kept in the browser underapiome:split-pane:<storageKey>and restored on the next visit. Use one key per page. Storage that is blocked or holds bad data is ignored. - Nothing reloads. Resizing changes only the grid's columns. A pane's content is not remounted, so an iframe in it does not reload.
- Narrow screens. In a container narrower than 40 rem (640 px) the panes stack in one column and the handles hide.
onLayoutChange(layout)is called after every change, with{ sizes, collapsed }keyed by pane id.paneClassNamesadds classes to a pane's wrapper.
Command palette providers
The shell has one command palette (⌘ K). A product with commands of its own adds them to that
palette with a provider. It does not mount a second palette. Apiome Suite's Designer uses
providers for its workspace search, git verbs, canvas actions and inspector tabs.
import { useCommandPaletteProvider } from '@/app/components/shell/commandPaletteProviders';
const groups = React.useMemo(
() => [
{
id: 'canvas',
heading: 'Canvas',
keepInCommandsMode: true,
commands: [
{
id: 'auto-layout',
group: 'canvas',
label: 'Auto-layout the canvas',
icon: 'network',
keywords: ['layout', 'arrange'],
disabled: false,
run: () => requestAutoLayout(),
},
],
},
],
[requestAutoLayout]
);
useCommandPaletteProvider('designer-canvas', groups);
- One list. A provider's groups are drawn in the same list as Favorites, Recent,
Jump to and Actions, with the same keyboard, filter and footer.
orderplaces a group (the built-ins are 100, 200, 300 and 400; a group with no order sits at 250, after Recent). - Ids are namespaced. Group and command ids become
<provider id>:<id>, so two providers cannot collide. Registering again under the same provider id replaces the groups. - Commands only. A group with
keepInCommandsModestays when the reader types>. Other provider groups are hidden, like Jump to. - Searching as the reader types.
useCommandPaletteSession()returns{ open, query }. A provider can search its own API while the palette is open. Mark the rows it returnsprematched: true: the palette then shows them even when the label does not contain the query. - Rows. A command has a
label, an optionalmetaline,keysfor a shortcut chip, adetailsentence shown on hover, anddisabledwith adisabledReason. Seticonto a name from the navigation icon set, or passiconComponentfor any other Lucide icon. A row either goes to anhref(remembered under Recent) or callsrun. - Opening it. Any entry point calls
openCommandPalette({ query }). For example, a⌘ Gbinding can open the palette withgitalready typed.
Type helpers
Four classes cover the secondary text used on every screen. Use one of them instead of writing a rule with a screen's own prefix.
| Class | Use it for | Text | Ink |
|---|---|---|---|
.hive-quiet | A muted line: an empty cell, a footer note, a card's identifier | 12 px | --fg-muted |
.hive-meta | A small line under a name, on its own row; long values wrap | 11 px | --fg-muted |
.hive-caps | A section label or eyebrow: 11 px, semibold, upper case, caps tracking | 11 px | --fg-muted |
.hive-label | The label of a form field drawn with a plain label element | 14 px, medium | --fg |
- The sizes are type tokens (
--fs-xs,--fs-2xs,--fs-sm), so they grow with the Font size preference. Each ink clears WCAG AA on the page surface in every theme. - They are plain classes, not Tailwind utilities, so they win over the base
pandh2rules. A screen rule later inglobals.csscan still add to one, for example a margin. - Until SUX-1.10 (apiome#6751), each screen had its own copy —
.prj-quiet,.cid-caps,.shd-meta,.sr-labeland 17 more with the same declarations. Those copies are gone, andapiome-ui/tests/shared-type-helpers-css.test.tsfails if one comes back. Eight per-screen rules that are not identical, such as.aud-quiet(14 px) and.vdlg-caps(an inline row with an icon), are still per-screen. - Nothing on screen changed. A browser comparison of every changed fixture, in the light and dark themes, found no difference in computed style.
Stepped dialogs
A dialog is normally as tall as its content and centred. In a dialog with steps or tabs, moving
to a longer or shorter step moves both edges, and the buttons move with them. Pass steps to
DialogContent to give the dialog a fixed frame instead:
<DialogContent size="lg" steps>
<DialogHeader>
<DialogTitle>Import classes</DialogTitle>
<Stepper steps={steps} current={current} fill />
</DialogHeader>
<DialogBody>{/* the current step */}</DialogBody>
<DialogFooter>{/* Back · Next · Import */}</DialogFooter>
</DialogContent>
- The dialog has one height on every step:
--dialog-steps-block-size(45 rem, 720 px at the default font size), or the window height less 3 rem when the window is shorter. The width is still itssize. DialogHeaderholds the title and the stepper or tab list.DialogFootersits at the bottom. Neither shrinks.DialogBodyfills the space between them and scrolls. A long step scrolls inside the frame; it does not make the dialog taller.stepsis opt-in. A dialog without it is unchanged, and no screen in the web app uses it yet. Studio uses it for its class import, class and property editors, canvas settings and export dialogs (SUX-2.3).Steppertakes an optionalonStepSelect(id, index). With it, every step is a button that jumps to that step; without it, the row only shows progress. Studio's class and property editors use it in Guided mode (SUX-2.5).
Where to see them
The design-system gallery is the /design-system route of apiome-ui. It needs no sign-in.
Overlays & banners has Open layered drawer, which opens a drawer, a dialog inside it and
a select inside that. It is the case the stacking scale exists for, and
apiome-ui/e2e/hive-z-index-scale.spec.ts checks it in a browser. Forms ends with the control
sizes: a row for each size, which apiome-ui/e2e/hive-control-sizes.spec.ts measures in a browser
at both densities. After them comes the form frame: the same two-section form on the page and, from
Open the form in a dialog, inside a dialog. Split pane has a form beside a
preview that keeps its width after a reload, and a three-pane layout whose side panes both
collapse.