Skip to main content

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​

FamilyTokensSpent through
Colour--color-* (surfaces, ink, lines, accents, status)bg-surface, text-fg, border-border …
Type--text-*, --font-sans, --font-monotext-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-12var(--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:

StepValueStepValue
--space-14 px--space-624 px (20 px at Compact density)
--space-28 px--space-832 px (24 px at Compact density)
--space-312 px--space-1040 px
--space-416 px--space-1248 px
--space-520 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.

StepValueUtilityUsed for
--z-base0z-baseThe page's own content
--z-raised10z-raisedOne item lifted over its neighbours: a card's buttons over its link, a table's header row
--z-sticky100z-stickySticky page headers, save bars, Studio's project and version toolbar
--z-chrome200z-chromeGlobal headers and the navigation rail
--z-floating300z-floatingCanvas toolbars, docked panels, notices that float over the chrome
--z-overlay1000z-overlayThe dimmed backdrop behind a dialog or drawer
--z-modal1010z-modalDialogs, drawers and the command palette
--z-popover1020z-popoverSelects, menus and tooltips, including those opened inside a dialog
--z-toast1030z-toastToasts
--z-alert1040z-alertConfirm 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.

SizeHeight tokenHeight (Comfortable)Height (Compact)PaddingTextCorner radius
Small--control-h-sm30 px26 px10 px12 pxrounded-sm
Medium (the default)--control-h36 px32 px12 px14 pxrounded-md
Large--control-h-lg42 px38 px16 px16 pxrounded-md

Each control names the sizes in its own way:

ControlSmallMediumLarge
Buttonsize="sm"no size, or size="default"size="lg"
Input, SelectTrigger, Textareasize="sm"no size, or size="md"size="lg"
Segmentedsize="sm"no size, or size="default"size="lg"
FormFieldsize="sm"no size, or size="md"size="lg"
  • A control with no size is medium. Existing screens did not change.
  • A FormField passes 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. A size set 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.
  • Input uses size for its height. The HTML size attribute, a width in characters, is not available. Set the width with a class such as w-40.
The control sizes specimen: a small, a medium and a large row, each with a button, an input, a select and a segmented switch of the same height, and a labelled input and text area under each rowThe control sizes specimen: a small, a medium and a large row, each with a button, an input, a select and a segmented switch of the same height, and a labelled input and text area under each row
Route/design-system

Forms​

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>
PartWhat it does
headerThe title. In a dialog, pass a DialogHeader.
Body (the children)One or more FormSections, 24 px apart. This part scrolls.
FooterSticks 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).
widthnarrow (560 px), default (720 px) or wide (960 px), as a maximum.
  • The spacing rule. A FormSection has a title, an optional description and its fields, 16 px apart. FormField is 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 as submitDisabledReason.
  • Secondary buttons never submit. A button in secondaryActions with no type becomes type="button", so Enter cannot press Cancel by mistake.
  • FormFrame is opt-in. No screen uses it yet; existing forms look the same as before.
The form frame specimen: a Project settings form with a Basics and an Access section, scrolled inside a well with its footer of Discard and Save project still visible, and an Open the form in a dialog button under itThe form frame specimen: a Project settings form with a Basics and an Access section, scrolled inside a well with its footer of Discard and Save project still visible, and an Open the form in a dialog button under it
Route/design-system

Unsaved 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
falseNothing. A clean form never asks.
true, the tab is closed or reloadedThe browser asks to confirm (its own wording).
true, a link to another page in the app is clicked, or Back is pressedA dialog asks Leave without saving? with Save, Discard and Cancel.
  • Save runs onSave, then leaves. If onSave returns false or throws, the page stays so its own error is visible. Without onSave, 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 #section are not stopped. Add data-unsaved-guard="ignore" to let one other link through.
  • A move the screen makes itself, such as router.push from a button, cannot be seen from outside: wrap it in guard.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>
The split pane specimen: a Site title form beside a preview frame with a drag line between them, and under it a three-pane Structure, Canvas and Inspector layoutThe split pane specimen: a Site title form beside a preview frame with a drag line between them, and under it a three-pane Structure, Canvas and Inspector layout
Route/design-system
  • One flexible pane. Exactly one pane has no defaultSize and takes the width that is left. Every other pane has a width in px, kept between minSize (default 120) and maxSize (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 a collapsible pane. 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 under apiome: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. paneClassNames adds 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. order places 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 keepInCommandsMode stays 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 returns prematched: true: the palette then shows them even when the label does not contain the query.
  • Rows. A command has a label, an optional meta line, keys for a shortcut chip, a detail sentence shown on hover, and disabled with a disabledReason. Set icon to a name from the navigation icon set, or pass iconComponent for any other Lucide icon. A row either goes to an href (remembered under Recent) or calls run.
  • Opening it. Any entry point calls openCommandPalette({ query }). For example, a ⌘ G binding can open the palette with git already 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.

ClassUse it forTextInk
.hive-quietA muted line: an empty cell, a footer note, a card's identifier12 px--fg-muted
.hive-metaA small line under a name, on its own row; long values wrap11 px--fg-muted
.hive-capsA section label or eyebrow: 11 px, semibold, upper case, caps tracking11 px--fg-muted
.hive-labelThe label of a form field drawn with a plain label element14 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 p and h2 rules. A screen rule later in globals.css can 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-label and 17 more with the same declarations. Those copies are gone, and apiome-ui/tests/shared-type-helpers-css.test.ts fails 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 its size.
  • DialogHeader holds the title and the stepper or tab list. DialogFooter sits at the bottom. Neither shrinks.
  • DialogBody fills the space between them and scrolls. A long step scrolls inside the frame; it does not make the dialog taller.
  • steps is 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).
  • Stepper takes an optional onStepSelect(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.