Skip to Content
CodeUI

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.

Do
Frame
Padding
1664
Shadow
Window
Padding
1664
Shadow
Rows touch inside their group, and groups sit 16px apart. The two groups read as two groups.
Don't
Frame
Padding
1664
Shadow
Window
Padding
1664
Shadow
Each label sits farther from its own rows than from the group above, so “Window” seems to belong to “Frame”. Without lines, space is the only thing that groups.

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

Fig. 1Concentric radius
outer 22 − padding 8 = inner 14
Drag the padding. The inner corners follow the outer one. Switch to "same radius" to see why equal radii look crooked: the gap is thick at the corners and thin along the sides.

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:

LevelRadius
Large dialog with inset chrome (export)24px
Island, floating bar, command menu22px
Group, popover, dialog, nudge16px
Field inside a 22px surface14px
Control: button, segmented track, option card12px
Row: menu row, nav item, segment10px
Badge, tag, keycap6px
Dot, switch, pillfull

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.

Do
BackgroundGradient
Search…
WindowmacOS
Card
Editor
Terminal
Flat islands, and one shadow on the menu that floats over them. Depth means something: this is on top.
Don't
BackgroundGradient
Search…
WindowmacOS
Card
Editor
Terminal
Every island lifted with a shadow and a highlight. The menu no longer stands out, and the page looks like a stack of cards.

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.

SizeCompactComfortableTouch
xs24px28px32px
sm (default)32px36px40px
md38px44px50px
lg46px52px58px

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.

On this page