Spacing Scale
Checked by spacing-scale (opt-in)
Spacing drifts. One card gets 14px of padding, the next one 16px, a third 18px because it looked tight that day. Nobody sees the 2px, but people feel that the page is slightly off, and every new screen adds another value.
Pick every space from a small scale whose steps grow as the gaps do, and extend it, or make it fluid, for page-level rhythm.
7 values: 6, 7, 9, 10, 14, 18, 22
The two cards look almost the same. The one-off version uses seven values, each picked by eye, and the check marks sit at three different distances from their text. The scale version uses four: 4, 8, 16 and 24. Things that should line up now do, and the next person to build a card has four answers instead of seven guesses.
Steps that grow
Start from 4px: 4, 8, 12, 16, 24, 32, 48, 64, then 96 and 128 for the space between page sections. The steps are 4px apart at the bottom, then 8, 16 and 32.
gap-61.5x the step belowWe notice spacing in proportion. Going from 8px to 12px adds 50% and is easy to see. Going from 48px to 52px adds 8% and nobody would notice, so it should not be a separate choice. Each step here is between 1.33x and 2x the one below.
The 8-point grid allows only multiples of 8. I find that too coarse for dense interfaces: 4px and 12px come up constantly for icon gaps and compact rows. Atlassian builds on 8px too, but adds half steps like 4, 6 and 12 for the same reason. A 4px base covers them and still lands on every multiple of 8.
In Tailwind
Tailwind v4 derives every spacing utility from one variable,
--spacing: 0.25rem, so gap-3 is 12px and p-6 is 24px. That is a 4px
base, but not a scale: gap-5, p-13 and mt-4.5 all work too. Don't reset
the namespace to fix that. Sizing utilities like w-64 and size-10 read the
same variable, so a reset removes them too. Keep the defaults, use only 1, 2,
3, 4, 6, 8, 12, 16, 24 and 32 for gaps and padding, and add a named step for what a multiple of 4px
can't say, like spacing that grows with the screen.
Usage
@import "tailwindcss";
/* Keep the default --spacing: 0.25rem. The steps are
1, 2, 3, 4, 6, 8, 12, 16, 24 and 32: 4px to 128px. */
@theme {
/* py-section: 64px on a phone, 128px on a wide screen */
--spacing-section: clamp(64px, 40px + 6vw, 128px);
}:root {
--space-1: 4px;
--space-2: 8px;
--space-3: 12px;
--space-4: 16px;
--space-6: 24px;
--space-8: 32px;
--space-12: 48px;
--space-16: 64px;
--space-24: 96px;
--space-32: 128px;
/* 64px on a phone, 128px on a wide screen */
--space-section: clamp(64px, 40px + 6vw, 128px);
}
.card {
padding: var(--space-6);
gap: var(--space-2);
}
.hero {
padding-block: var(--space-section);
}An app screen rarely needs more than 64px. A marketing page wants far more
between sections, and a fixed 128px is too much on a phone. A fluid step like
section covers both without a breakpoint per section. The scale decides which
values exist. Whitespace decides where the big ones go.
Resources
Atlassian spacing - A production spacing scale with guidance on which range to use for what.
The 8-Point Grid - The case for multiples of 8, paired with a 4pt baseline grid for text.
Tailwind theme variables - How the spacing namespace works and how to replace the default values.
Tailwind CSS v4.0 - Why every spacing utility in v4 is derived from a single variable.