Complete the lesson quiz and earn 250 XP.
Why do companies like Google, Apple, Uber, and Shopify base their design systems on multiples of 8 (8px, 16px, 24px, 32px, 48px, 64px)?
The reasons are mathematical and physical:
4px and 2px) without generating messy sub-pixel decimals (e.g., 1.5px or 3.333px).7.5px or 10.5px).There are two primary ways teams implement the 8-point spatial system in digital products:
Pro Tip: Almost all modern design systems (Shopify Polaris, GitHub Primer, Uber Base) use the Soft Grid. It provides predictable vertical rhythm while giving typography freedom to flow naturally.
While 8px is the macro baseline, sometimes 8px is too coarse for micro-interactions and compact UI elements.
For example, inside a compact badge or table row, an 8px padding might make the element feel bloated, while 0px is cramped. This is where the 4-point micro-grid comes in:
space-4 (half of 8) and occasionally space-12 (1.5x) for fine-grained typographic alignment, icon padding, and border offsets.To prevent arbitrary values like 11px, 19px, or 27px, a design system establishes a fixed, named spatial scale:
space-0: 0pxspace-4: 4px (Micro, tight icon gaps)space-8: 8px (Compact padding, related text items)space-12: 12px (Medium-compact padding)space-16: 16px (Standard card padding, default form gaps)space-24: 24px (Section grouping, large card spacing)space-32: 32px (Major module separation)space-48: 48px (Page section gutters)space-64: 64px (Hero spacing, major layout breaks)By limiting designers and developers to these 9 tokens, you eliminate visual friction and speed up design reviews.
The Gestalt Law of Proximity states that objects placed close together are perceived by the human brain as belonging to the same group, while objects spaced further apart are perceived as distinct entities.
In UI design, incorrect spacing confuses user mental models:
16px) is greater than or equal to the space between the input and the next field's label (16px), users struggle to tell which label belongs to which input.4px or 8px) must always be noticeably smaller than the space between distinct groups (Field A $\leftrightarrow$ Field B: 24px).Different products demand different spatial densities. An e-commerce mobile shopping app benefits from generous whitespace, while a financial trading terminal requires dense data tables to fit 40 stocks on one screen.
Mature design systems support Density Modes using semantic spacing variables:
| Token | Compact (Data Heavy) | Default (Standard) | Spacious (Marketing/Consumer) |
|---|---|---|---|
space-table-cell-y | 4px | 8px | 16px |
space-button-padding-y | 6px | 10px | 14px |
space-card-padding | 12px | 16px | 24px |
By adjusting density via tokens rather than hardcoded component rewrites, the same table component can serve both enterprise analysts and casual consumers.
It is critical to separate Layout Grid spacing (the global scaffold that positions cards on a page) from Component Spacing (the internal anatomy of a component):
24px on desktop, 16px on mobile), and outer page margins.16px), the gap between an icon and button text (8px), or the space between avatar and user name (12px).Rule of Component Isolation: A component should never declare external margins on its root container (margin-top: 24px). Spacing between components is the responsibility of the parent layout container (using CSS Flexbox gap or CSS Grid gap).
On a 375px iPhone screen, a 64px section margin consumes over 15% of the total screen height, forcing users into excessive scrolling. On a 2560px ultra-wide monitor, a 16px margin feels cramped and suffocating.
Responsive design systems solve this with responsive spatial tokens:
space-section-gap = 24pxspace-section-gap = 32pxspace-section-gap = 48px or 64pxclamp() functions interpolate smoothly: clamp(1.5rem, 4vw + 0.5rem, 4rem).Review this real-world CSS from a messy feature branch:
.product-card {
padding: 13px 19px 21px 15px;
margin-bottom: 27px;
}
.product-card .title {
margin-bottom: 7px;
}
.product-card .price {
margin-bottom: 11px;
}
Notice the complete lack of mathematical harmony: four different uneven paddings, non-standard 7px and 11px margins, and a 27px bottom margin.
Refactoring to the 8-Point Spatial System:
16px (space-16) or 16px 24px (space-16 space-24).8px (space-8).16px (space-16).margin-bottom: 27px and let the parent grid use gap: space-24.