Skip to content
Space & shapeMarkdown

Spacing

Spacing uses a closed 12-step scale on a 4px grid from 4px to 128px. Steps 1–12 (4–48px) govern components, and steps 16–32 (64–128px) govern sections.

Spacing scale

ClassCSS varpxremScopeBar
p-1 / gap-1--space-14px0.25remComponents (4–48px)
p-2 / gap-2--space-28px0.5remComponents (4–48px)
p-3 / gap-3--space-312px0.75remComponents (4–48px)
p-4 / gap-4--space-416px1remComponents (4–48px)
p-6 / gap-6--space-624px1.5remComponents (4–48px)
p-8 / gap-8--space-832px2remComponents (4–48px)
p-10 / gap-10--space-1040px2.5remComponents (4–48px)
p-12 / gap-12--space-1248px3remComponents (4–48px)
p-16 / gap-16--space-1664px4remSections (64–128px)
p-20 / gap-20--space-2080px5remSections (64–128px)
p-24 / gap-24--space-2496px6remSections (64–128px)
p-32 / gap-32--space-32128px8remSections (64–128px)

Use --space-1 through --space-12 inside cards, controls, and form groups. Reserve --space-16 through --space-32 for section padding and homepage white space.

Usage

Apply spacing utilities in Tailwind CSS or custom properties in CSS:

<section className="py-16">
  <div className="flex flex-col gap-4 rounded-lg border border-border bg-card p-6">
    <h2 className="font-display text-h4">Card heading</h2>
    <p className="font-sans text-body text-muted-foreground">
      Component padding stays within 4–48px.
    </p>
  </div>
</section>
.panel {
  padding: var(--space-6);
  display: grid;
  gap: var(--space-4);
}

Do and don't

Do: Separate component and section scales
Use steps 1–12 (4–48px) for padding and gaps inside components, and steps 16–32 (64–128px) for vertical section rhythm.
Don't: Use arbitrary spacing values
Do not write p-[18px] or gap-5 because off-grid values break alignment and fail to compile under the locked Tailwind theme.

Accessibility

  • Emit all spacing tokens in rem (px / 16) so layout breathing room scales proportionally with browser text zoom.
  • Maintain at least 8px (--space-2) between adjacent interactive targets to prevent accidental taps.

Rationale

Locking spacing to 12 discrete steps removes arbitrary pixel nudging and keeps component density consistent across pages.