Foundations

Spacing

A 4 px base unit, and one idea that does most of the work: things placed close together are read as related. In a patient record that inference is a clinical claim, made silently, by whoever set the padding.

Stable · v1.0 WCAG 2.2 AA SC 2.5.8

Overview

Spacing is usually treated as taste. It is closer to grammar: proximity is how an interface says "these belong together" without writing it down. Card makes that claim at the level of a boundary; spacing makes it continuously, everywhere, at a finer grain and with no border to make it visible.

The practical consequence is that a value and its unit must sit closer to each other than the value sits to its neighbour — and if they do not, a clinician scanning a column will pair them wrongly at a glance and only catch it on a second read they may not take.

Systematic

Every gap is a multiple of four. Arbitrary values are how a system drifts, and they make density modes impossible to apply consistently.

Relational

Distance encodes association. Related things are closer than unrelated ones, and the difference is large enough to read without measuring.

Generous where it counts

Density is bought from whitespace between groups, never from touch targets, never from the gap that separates a safe action from a destructive one.

The scale

Ten steps on a 4 px base. The token definitions live in Tokens; this page is about which one to reach for.

Spacing scale
--njt-s-14px · icon to its label
--njt-s-28px · within a control; minimum between adjacent targets
--njt-s-312px · between related controls
--njt-s-416px · default gap; card padding
--njt-s-520px · between fields in a form
--njt-s-624px · between groups within a region
--njt-s-832px · between sections
--njt-s-1040px · separating a destructive action
--njt-s-1248px · between major regions
--njt-s-1664px · page-level rhythm

Proximity is a claim

The rule that matters

Within any group, the internal gaps must be at least one step smaller than the gap separating that group from the next. Where they are equal, grouping is ambiguous; where they are inverted, the interface is asserting a relationship that does not exist.

Do
Peak hs-cTnI
1 240 ng/L
Baseline hs-cTnI
14 ng/L

4 px inside a pair, 24 px between pairs. Which label belongs to which value is unambiguous at a glance.

Don't
Peak hs-cTnI
1 240 ng/L
Baseline hs-cTnI
14 ng/L

Equal gaps throughout. Scanning downward, "1 240 ng/L" pairs as readily with the label beneath it as the one above.

Separation minimums

BetweenMinimumWhy
Adjacent touch targets8 px The gap itself must not be tappable. WCAG 2.5.8 target spacing; see Button.
A destructive action and its neighbour40 px A mis-tap adjacent to "Discard draft report" must land on nothing. Separation is cheaper than a confirmation dialog.
Stacked alarm banners8 px Enough that two alarms read as two, close enough that the stack reads as one region.
A value and its unit4 px, non-breaking They are one thing. The gap never becomes a line break.
Form fields20 px Enough that an error message under one field is not read as helper text for the next.

Density

Three modes, differing only in padding. Density never removes information — the same rule as Data grid.

ModeRow paddingUse
comfortable12 px Default. Mandatory on any touch surface.
default8 pxPointer-operated workstation UI.
compact4 px Dense analytic review, pointer only, no clinical priority in the rows.

Density is a property of a region, not of individual components. Mixing densities within one panel breaks the proximity rule, because the reader cannot tell whether a smaller gap means "more related" or "denser table".

Spacing and scale factor

Every spacing token is expressed in rem, so applying a deployment scale factor moves type, spacing and hit areas together. This is what makes the physical touch floor hold on a cart display — see Scaling & displays. Hard-coded pixel gaps break that guarantee silently, which is why the token set exists at all.

Outcomes of use

What this contributes to, in the terms of Usability & context of use.

Do's and don'ts

Do

8 px minimum between adjacent targets, so the gap itself is not tappable.

Don't

Touching targets. Gloved, on a moving cart, which one you hit near the seam is a coin toss.

Do

40 px around a destructive action, so a near-miss lands on nothing. Cheaper than another confirmation step.

Don't

4 px between cancel and permanent deletion. The mis-tap that costs a report is one finger-width away.

Clinical safety notes

Risk controls carried by this foundation

Trace these in your risk file (ISO 14971) and usability engineering file (IEC 62366-1).

NotJustAnyMed.Tech Design System · Spacing · v1.0 · draft for review