Foundations
Spacing
One scale of gaps for every padding, margin and gap in the product. If a space isn't on the scale, it isn't allowed.
Why we chose this
One scale, built on a 4px base, for every padding, margin and gap. Related things sit close, separate things sit far apart, and the whole product keeps one rhythm. Changing it later is a one-line edit in tokens.json.
Use it for
- Inside components, like buttons, tags and fields:
space-1tospace-6 - Between blocks on a page:
space-7tospace-12 - Between page sections:
space-16andspace-24
Don't
- Type a value like
13px. If it isn't on the scale, it isn't allowed. - Use space to set a size. Sizing is a separate foundation.
- Use a small gap between unrelated things.
The scale
The scale is built on a 4px base: almost every step is a multiple of 4, with a few half-steps (2, 6, 10px) for tight details like icon nudges. CSS variables can't contain a dot, so space-2.5 is --space-2-5 in CSS. In Tailwind the dot stays (p-2.5).
Choosing a step
Where components use it
Read from components.css. This is the spacing the existing components already use, so new components should stay inside it.
Padding and gap
Pick values to see how they work together. Padding is space inside a box. Gap is space between its children.
Page layout
| Use | Token | Value |
|---|---|---|
| Side gutter, mobile (below 768px) | gutter-mobile = space-4 | |
| Side gutter, desktop (768px and up) | gutter-desktop = space-6 | |
| Minimum height of buttons and fields | control-min-height = space-11 | |
| Between related blocks | space-8 | 32px |
| Between sections inside a page | space-12 | 48px |
| Large and major section padding | space-16, space-24 | 64px, 96px |
Mobile and web
Spacing tokens are fixed, but which one you pick changes with screen size. The usual pattern is to step down one or two sizes on phones:
| Where | Mobile | Web |
|---|---|---|
| Page side gutter | space-4 (16px) | space-6 (24px) |
| Between page sections | space-12 (48px) | space-16 to space-24 |
| Card padding | space-4 | space-6 |
The gutters are defined tokens. The section and card pairs are a recommended pattern, not yet enforced in code.
Rules
| Rule | Reason |
|---|---|
Only use tokens: padding: var(--space-4), never padding: 15px. | Keeps every screen on the same rhythm. |
Prefer gap on the parent over margins on children. | Spacing belongs to the layout, so moving or removing an item never leaves stray margin. |
| Closer means more related: small gaps inside a group, larger gaps between groups. | Spacing is how people see what belongs together. |
Interactive targets are at least 44px (space-11), never below the 24px floor. | Easy to tap and click. Add padding rather than enlarging the text. |
| Don't skip the scale to "fine tune". If none fits, ask for a new token. | One-off values are how systems drift. |
Related items close (space-2), then a bigger gap before the next group.
.card {
display: flex;
flex-direction: column;
gap: var(--space-4);
padding: var(--space-6);
}Arbitrary values like 13px that aren't on the scale.
.card {
display: flex;
flex-direction: column;
padding: 22px;
}
.card > * + * { margin-top: 13px; }