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-1 to space-6
  • Between blocks on a page: space-7 to space-12
  • Between page sections: space-16 and space-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.



Title
Description
Action

Page layout

UseTokenValue
Side gutter, mobile (below 768px)gutter-mobile = space-4
Side gutter, desktop (768px and up)gutter-desktop = space-6
Minimum height of buttons and fieldscontrol-min-height = space-11
Between related blocksspace-832px
Between sections inside a pagespace-1248px
Large and major section paddingspace-16, space-2464px, 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:

WhereMobileWeb
Page side gutterspace-4 (16px)space-6 (24px)
Between page sectionsspace-12 (48px)space-16 to space-24
Card paddingspace-4space-6

The gutters are defined tokens. The section and card pairs are a recommended pattern, not yet enforced in code.

Rules

RuleReason
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.
Do
Label
Input

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);
}
Don't
Label
Input

Arbitrary values like 13px that aren't on the scale.

.card {
  display: flex;
  flex-direction: column;
  padding: 22px;
}
.card > * + * { margin-top: 13px; }