Home
Bookmarks
Leagues
LEARN
Courses
Career Paths
Assessments
Tutorials
Arcade
Glossary
GROW
Certifications
Log in
Glossary
Log inSign up
Courses/Introduction to Design Systems/Spacing & Sizing: The 8-Point Spatial Grid
Level 3 · Design Tokens & Foundations

Spacing & Sizing: The 8-Point Spatial Grid

15 min read
9 exercises
250 XP
PRO
Unlock with Pro

Ready to test what you learned?

Complete the lesson quiz and earn 250 XP.

Unlock quiz

Topics in this lesson

The Mathematical Foundation of the 8-Point GridHard Grid vs Soft Grid ImplementationThe 4-Point Micro-Grid for Fine DetailingThe Standard Spacing Token ScaleGestalt Law of Proximity in Spatial LayoutDensity Modes: Compact vs Default vs SpaciousLayout Grids vs Component Internal SpacingResponsive Spacing & Breakpoint TokensChallenge: Refactoring an Inconsistent Card Layout

From Course

📘
Introduction to Design SystemsBeginner · 16 lessons
Spacing & Sizing: The 8-Point Spatial Grid

Lesson

Spacing & Sizing: The 8-Point Spatial Grid

The Mathematical Foundation of the 8-Point GridHard Grid vs Soft Grid ImplementationThe 4-Point Micro-Grid for Fine DetailingThe Standard Spacing Token ScaleGestalt Law of Proximity in Spatial LayoutDensity Modes: Compact vs Default vs SpaciousLayout Grids vs Component Internal SpacingResponsive Spacing & Breakpoint TokensChallenge: Refactoring an Inconsistent Card Layout
Unlock lesson
Complete lesson and earn 250 PX
Exercise #1

The Mathematical Foundation of the 8-Point Grid

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:

  1. Clean Division: 8 divides cleanly by 2 and 4, allowing easy half-steps (4px and 2px) without generating messy sub-pixel decimals (e.g., 1.5px or 3.333px).
  2. Screen Resolution Scaling: Modern displays use pixel densities of 1x, 2x (Retina), 3x (OLED phones), and 1.5x/2.5x (Android). An 8px value scales cleanly into whole integers across every device multiplier:
    • $8 \times 1 = 8$
    • $8 \times 1.5 = 12$
    • $8 \times 2 = 16$
    • $8 \times 3 = 24$ If you used an odd base like 5px or 7px, multiplying by 1.5x produces blurry sub-pixel distortion (7.5px or 10.5px).
Exercise #2

Hard Grid vs Soft Grid Implementation

There are two primary ways teams implement the 8-point spatial system in digital products:

  1. Hard Grid: Every single element's width, height, and absolute coordinate position must be snapped to an explicit 8px background grid. Verdict: Extremely rigid; breaks easily when dealing with dynamic text lengths, internationalization, and fluid responsive viewports.
  2. Soft Grid (The Modern Standard): Elements themselves have fluid or content-driven dimensions, but all internal padding, external margins, and gap spacings between elements must strictly use multiples of 8.

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.

Exercise #3

The 4-Point Micro-Grid for Fine Detailing

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:

  • Permissible 4px half-steps: Spacing tokens include space-4 (half of 8) and occasionally space-12 (1.5x) for fine-grained typographic alignment, icon padding, and border offsets.
  • Rules of Engagement: 4px spacing should be reserved for tight internal component padding, small icon-to-label gaps, and borders. Structural page layout and card margins should remain strictly 8px or higher.
Exercise #4

The Standard Spacing Token Scale

To prevent arbitrary values like 11px, 19px, or 27px, a design system establishes a fixed, named spatial scale:

  • space-0: 0px
  • space-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.

Exercise #5

Gestalt Law of Proximity in Spatial Layout

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:

  • If the space between a form label and its input (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.
  • The Proximity Rule: The space between related items (Label $\leftrightarrow$ Input: 4px or 8px) must always be noticeably smaller than the space between distinct groups (Field A $\leftrightarrow$ Field B: 24px).
Exercise #6

Density Modes: Compact vs Default vs Spacious

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:

TokenCompact (Data Heavy)Default (Standard)Spacious (Marketing/Consumer)
space-table-cell-y4px8px16px
space-button-padding-y6px10px14px
space-card-padding12px16px24px

By adjusting density via tokens rather than hardcoded component rewrites, the same table component can serve both enterprise analysts and casual consumers.

Exercise #7

Layout Grids vs Component Internal Spacing

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):

  1. Layout Grid (Macro Space): Typically an 8-column or 12-column responsive grid with fluid percentage column widths, fixed gutters (e.g., 24px on desktop, 16px on mobile), and outer page margins.
  2. Component Spacing (Micro Space): The internal padding of a card (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).

Exercise #8

Responsive Spacing & Breakpoint Tokens

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:

  • Stepped Spatial Breakpoints: Tokens adapt across defined viewport boundaries:
    • Mobile (< 640px): space-section-gap = 24px
    • Tablet (640–1024px): space-section-gap = 32px
    • Desktop (> 1024px): space-section-gap = 48px or 64px
  • Fluid Clamping: Alternatively, modern CSS clamp() functions interpolate smoothly: clamp(1.5rem, 4vw + 0.5rem, 4rem).
Exercise #9

Challenge: Refactoring an Inconsistent Card Layout

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:

  • Card padding: Uniform 16px (space-16) or 16px 24px (space-16 space-24).
  • Title to price gap: 8px (space-8).
  • Price to CTA button gap: 16px (space-16).
  • Card container: Remove margin-bottom: 27px and let the parent grid use gap: space-24.