Skip to content

FoundationsSpacing

A 4 px base. Thirteen steps. No magic numbers.

Every gap, padding, and margin in the system is on a 4 px base. The thirteen named tokens are the only values that should ever appear in a component.

13 spacing tokens4 px baseNo magic numbers

The scale

The scale is a simple 0–96 px progression. The named tokens are intentional because Tailwind's numeric classes (p-2, p-4) are not self-documenting — they don't tell the next contributor what role a particular gap is playing.

space-00 · 0px
space-10.25rem · 4px
space-20.5rem · 8px
space-30.75rem · 12px
space-41rem · 16px
space-51.25rem · 20px
space-61.5rem · 24px
space-82rem · 32px
space-102.5rem · 40px
space-123rem · 48px
space-164rem · 64px
space-205rem · 80px
space-246rem · 96px

Mapping to Tailwind classes

The names above are documentation-only. In code, we use Tailwind's numeric utilities, which the design system constrains to the values in this table.

TokenTailwindPixels
space-1p-1, m-1, gap-14px
space-2p-2, m-2, gap-28px
space-3p-3, m-3, gap-312px
space-4p-4, m-4, gap-416px
space-6p-6, m-6, gap-624px
space-8p-8, m-8, gap-832px
space-12p-12, m-12, gap-1248px
space-16p-16, m-16, gap-1664px

Rhythm, not randomness

The system has rules for what gap goes where. The rules are short, and the reason for each one is the same: a consistent rhythm is what makes a long page feel like a single document, not a list of sections.

WhereUse
Component internal paddingspace-2 → space-4 (8 → 16 px)
Form field gapspace-2 (8 px)
Card gap (related cards)space-3 (12 px) or space-4 (16 px)
Section gap (same page)space-12 (48 px) on mobile, space-20 (80 px) on desktop
Page-level vertical rhythmspace-16 → space-24 (64 → 96 px)
Within prosespace-4 (16 px) between paragraphs

A worked example

The same card, the same content, the same space-4 / space-6 / space-8 layout across both desktop and mobile.

Demo

Section label

A worked example of the spacing system

The eyebrow is space-2 below the card top. The h3 is space-3 below the eyebrow. The body is space-4 below the h3. The CTA is space-6 below the body. Each gap is a named token; none of them is a magic number.

Read more

Section vertical rhythm

Sections on every page are separated by space-12 (48 px) on mobile and space-20 (80 px) on desktop. The two values are not a responsive tweak — they are the design: a section on desktop should breathe more than a section on mobile because the screen is wider and the eye travels further.

css
.ds-section {
  margin-top: 3.5rem; /* 56 px on mobile */
}

@media (min-width: 768px) {
  .ds-section {
    margin-top: 4.5rem; /* 72 px on tablet, 80 px on desktop */
  }
}

Why this scale

The 4 px base is the smallest grid that still allows meaningful differences between adjacent steps. A 2 px base (typical on Windows desktop) reads as cramped next to a 19 px body; a 5 or 8 px base (typical on iOS HIG and some Western design systems) loses the fine control needed for compact UI like form fields and table cells.

The thirteen steps are enough to express all of the system's vertical relationships without giving a component author the option to pick a value outside the system. If a layout needs a 22 px gap, the right answer is to pick space-5 (20 px) or space-6 (24 px) — not to invent a new value.