The 8pt Grid and Spacing Systems: How to Space Layouts Consistently
Inconsistent spacing is one of the most common reasons a layout feels slightly “off” even when the colors and fonts are fine: 13px here, 17px there, 22px somewhere else. A spacing system replaces those one-off values with a small, predictable set, and the 8-point grid is the most popular way to define one.
What the 8pt grid is
The rule is simple: all spacing and sizing values are multiples of 8. Padding, margins, gaps, component heights and widths use 8, 16, 24, 32, 40, 48 and so on.
Why 8?
- It divides evenly. Common screen widths and breakpoints (320, 360, 768, 1024, 1280, 1440) are all divisible by 8, so layouts fit cleanly.
- It scales cleanly. On 1.5x and 2x screens, multiples of 8 become whole physical pixels (8 × 1.5 = 12), avoiding blurry half-pixel edges.
- It’s easy to halve. 8 → 4 → 2 stays whole, which a 5- or 10-based system doesn’t.
- It limits choices. Fewer options mean faster decisions and more consistent results.
Material Design popularised the 8dp grid, and most major design systems use 8 or 4 as their base unit.
The 4pt half-step
Strict 8pt spacing is sometimes too coarse for small components: icon-to-label gaps, badge padding, tight list items. Most systems therefore allow 4pt steps for small values (4, 8, 12, 16) and 8pt steps above that. Typography line heights are often set on a 4pt baseline grid too, so text aligns with the spacing rhythm.
Building a spacing scale
A spacing scale is a fixed list of allowed values. Three common shapes:
| Progression | Example values (px) | Character |
|---|---|---|
| Linear multiples of 8 | 8, 16, 24, 32, 40, 48, 56, 64 | Even steps; many similar large values |
| Practical (fine at small sizes, coarse at large) | 4, 8, 12, 16, 24, 32, 48, 64, 96, 128 | The most common in real systems |
| Doubling | 4, 8, 16, 32, 64, 128 | Few options; big jumps |
The “practical” scale works best because small spaces need fine control (the difference between 8 and 12px padding is obvious in a button) while large spaces don’t (nobody can tell 88 from 96px between sections). The spacing scale generator above builds all of these as CSS variables or JSON tokens.
The internal ≤ external rule
A useful principle from Gestalt psychology’s law of proximity: elements that are close together are perceived as a group. In layout terms, the space inside a group should be smaller than the space between groups.
| Relationship | Typical spacing |
|---|---|
| Icon and its label | 4–8px |
| Label and its input | 4–8px |
| Fields in a form group | 16–24px |
| Between form sections | 32–48px |
| Between page sections | 64–128px |
When internal spacing is larger than external spacing, users misread which items belong together. A heading should be closer to the paragraph it introduces than to the paragraph above it. Getting this right does more for clarity than any visual decoration.
Spacing tokens
Store the scale as named tokens, so designers and developers use the same values:
:root {
--space-1: 4px;
--space-2: 8px;
--space-3: 12px;
--space-4: 16px;
--space-5: 24px;
--space-6: 32px;
--space-7: 48px;
--space-8: 64px;
}Name them by step, not by value (--space-4, not --space-16). Then you can retune the scale later without renaming everything. Some teams use t-shirt sizes (xs, sm, md, lg, xl) for the same reason. In Figma, the same values can live in variables and Auto Layout gaps.
Using rem instead of px (--space-4: 1rem) makes spacing scale with the user’s font size setting, keeping proportions between text and space. Our px vs rem guide explains when that’s desirable.
Component sizes on the grid
The grid applies to sizes as well as spacing:
- buttons 32, 40 or 48px tall,
- inputs 40 or 48px,
- icons 16, 20, 24 or 32px,
- avatars 24, 32, 40, 48 or 64px.
Text inside components won’t always land exactly on the grid, because font metrics vary. Aim to make the container sizes and the spaces between components follow the grid, rather than forcing every text baseline.
Layout grids versus spacing grids
These are related but different:
- A spacing grid (8pt) defines the allowed values for padding, margins and sizes.
- A layout grid (for example 12 columns with 24px gutters) defines where content sits horizontally.
They work best together: gutters and margins from the spacing scale, columns calculated from the container width. Our layout grid guide covers columns.
Responsive spacing
Spacing that looks generous on a desktop can waste space on a phone. Common approaches:
- step down one or two scale values on small screens (64px sections become 40px),
- use fluid values with
clamp()that scale between two scale steps, as described in our fluid typography guide.
Auditing spacing in an existing product
If a product grew without a system, you can introduce one gradually:
- Collect the current values. Browser DevTools and design-file inspectors make it easy to list every margin, padding and gap in use. Most products discover dozens of slightly different values.
- Map each value to the nearest step of your new scale: 13px becomes 12px, 22px becomes 24px, 30px becomes 32px.
- Replace values with tokens component by component, starting with the most used components (buttons, inputs, cards).
- Review visually. Most changes of 1–3px are invisible individually, but together they make the interface noticeably tidier.
- Prevent drift. Lint rules (for example stylelint rules that only allow spacing tokens) and design-file variables stop new one-off values creeping back in.
The goal isn’t perfection on day one; it’s a shared vocabulary that every new screen uses.