Space and shape
@codeui/inkstone v0.3.0
A 4px grid, concentric radii, shadows only on what floats, and controls sized to be hit.
Space
Spacing uses a 4px grid with 2px half steps: 2 · 4 · 6 · 8 · 12 · 16 · 24 · 32. Every gap comes from this list, written as a token. CodeImage currently writes the same 8px gap as '8px' in some files and spacing['2'] in others. The kit is where those two spellings become one.
Proximity does the grouping
There are no lines between groups, so space alone shows what belongs together. The rule is simple: the space inside a group is always smaller than the space between groups. A title and its description sit 2–4px apart. Rows in a group touch. Groups sit 16–24px apart. A heading has more space above it than below, so it attaches to the content that follows.
The shell
Everything sits 6px from the window edge and 6px from its neighbours, so the page between islands reads as a thin seam and the space goes inside the islands. The header has no bar of its own. It is as tall as its controls (36px) and reads as the first row of islands, with its edges aligned to the islands below.
Radius follows nesting
A corner inside another corner should be concentric with it: inner radius = outer radius − the padding between them. If both use the same radius, the gap between them is thick at the corners and thin along the sides, and the inner box looks crooked even though it is not.
The radius therefore depends on where an element sits, not on what kind of component it is:
| Level | Radius |
|---|---|
| Large dialog with inset chrome (export) | 24px |
| Island, floating bar, command menu | 22px |
| Group, popover, dialog, nudge | 16px |
| Field inside a 22px surface | 14px |
| Control: button, segmented track, option card | 12px |
| Row: menu row, nav item, segment | 10px |
| Badge, tag, keycap | 6px |
| Dot, switch, pill | full |
A theme changes the shape with one value, --cui-radius-scale, which multiplies every radius except none and full. The levels keep their ratios, so nesting still reads right at any scale. At 0 every corner is square.
The kit currently has eleven radius tokens, and some differ by only 1–2px (7, 9, 10, 12, 14, 16, 18…). CodeImage uses 22, 18 and 16px for things that are all "a floating island". The table above is the target. The 7, 9 and 18px tokens go away.
Content near a large radius also needs room. CodeImage's logo moved to 16px from the island edge because at 8px it looked "troppo attaccato a sx", pushed too far into the corner.
Elevation
An island in the layout has no shadow, because it is carved into the page and not placed on top of it. Only surfaces that float over something else get a shadow: menus, popovers, the command menu and dialogs. In dark mode they also get a 1px inner ring, since a shadow on a near-black page is barely visible.
A floating surface has no backdrop unless it is modal. A picker that dimmed the page would hide the content it is supposed to change.
Size
Buttons, icon buttons, fields, select triggers and segmented tracks share one height scale.
| Size | Compact | Comfortable | Touch |
|---|---|---|---|
xs | 24px | 28px | 32px |
sm (default) | 32px | 36px | 40px |
md | 38px | 44px | 50px |
lg | 46px | 52px | 58px |
Comfortable is the default density. Compact multiplies heights by 0.875, and touch multiplies them by 1.125. Heights round to the nearest 2px. A coarse pointer selects touch density automatically. Set data-cui-density="compact|comfortable|touch" on an element to set density for its subtree. Font sizes stay tied to the control size.
Checkbox, Radio and Switch use their own geometry. Menu, listbox, select, combobox, command menu and navigation rows use --cui-control-height-sm (32px compact, 36px comfortable, 40px touch). A segment fills the space inside the track padding.
- Choose a size and density that give standalone targets at least 28px on desktop and 40px on a phone. A tiny mark keeps a 24px hit box.
- A row has a fixed 20px slot for its leading icon, so the text of every row lines up even when some rows have no icon.
- An icon-only button always has a tooltip and an accessible name.