Design Systems · Lesson 06 / 13
Spacing, layout & other foundations
The remaining foundations of a design system: spacing scale and semantic spacing, grids and breakpoints, sizing, radius, elevation, z-index, motion tokens and logical properties for RTL.
3 min read · 5 quiz questions
Spacing scale
A design system defines a fixed spacing scale, usually based on 4 or 8 pixels. Every padding, margin and gap comes from this scale. It makes layouts consistent and removes hundreds of tiny decisions.
| Token | Value | Common use |
|---|---|---|
| space-0 | 0 | Reset |
| space-1 | 4px | Icon to text, tight gaps |
| space-2 | 8px | Inside small components, between related items |
| space-3 | 12px | Input padding, list item gaps |
| space-4 | 16px | Card padding (mobile), default gap |
| space-6 | 24px | Card padding, gaps between groups |
| space-8 | 32px | Between sections inside a page |
| space-12 | 48px | Between major sections |
| space-16 | 64px | Page sections on desktop |
| space-24 | 96px | Large marketing sections |
Live preview
Semantic spacing
Just like colour, some systems add semantic spacing tokens that describe purpose, mapped to the scale. They make intent clearer and allow density changes (comfortable vs compact) by remapping.
:root {
--space-inset-sm: var(--space-2); /* padding inside small components */
--space-inset-md: var(--space-4); /* padding inside cards */
--space-stack-sm: var(--space-2); /* vertical gap between related items */
--space-stack-lg: var(--space-8); /* vertical gap between sections */
--space-inline-sm: var(--space-2); /* horizontal gap: icon + label */
}
[data-density="compact"] {
--space-inset-md: var(--space-3);
--space-stack-lg: var(--space-6);
}Grid and breakpoints
- Document the grid in Figma as layout grid styles, and in code as CSS grid utilities or layout components.
- Offer layout components (Stack, Inline, Grid, Container) so developers don't rebuild spacing logic everywhere.
- Define max content widths for reading (about 720px) and for app pages (1280–1440px).
| Breakpoint token | Min width | Columns | Margin | Gutter |
|---|---|---|---|---|
| bp-sm | 0 | 4 | 16px | 16px |
| bp-md | 640px | 8 | 24px | 16px |
| bp-lg | 1024px | 12 | 32px | 24px |
| bp-xl | 1280px | 12 | auto (max 1280px content) | 24px |
Sizing
Consistent sizes for controls make interfaces line up. Typical sizing tokens:
- Control heights: sm 32px, md 40px, lg 48px — shared by buttons, inputs and selects so they align in a row.
- Icon sizes: 16, 20, 24, 32px.
- Avatar sizes: 24, 32, 40, 56, 96px.
- Minimum touch target: 44px (or 48px), even when the visible control is smaller.
Radius, borders and elevation
| Token | Value | Use |
|---|---|---|
| radius-none | 0 | Tables, full-bleed images |
| radius-sm | 4px | Badges, small controls |
| radius-md | 8px | Buttons, inputs, cards |
| radius-lg | 16px | Modals, sheets, large cards |
| radius-full | 9999px | Pills, avatars, toggles |
| border-width-default | 1px | Inputs, cards, dividers |
| border-width-strong | 2px | Focus rings, selected states |
| shadow-1 / 2 / 3 | Layered shadows | Raised, overlay, modal |
Radius is part of brand personality: sharp corners feel precise and serious; large radii feel friendly and soft. Pick a direction and apply it consistently. A nested element should usually have a smaller radius than its container (outer radius = inner radius + padding).
Z-index and layering
Without a system, z-index values escalate (999, 9999, 99999…). Define named layers instead:
:root {
--z-base: 0;
--z-raised: 10; /* sticky table headers */
--z-dropdown: 100;
--z-sticky: 200; /* sticky page header */
--z-overlay: 300; /* backdrop */
--z-modal: 400;
--z-toast: 500;
--z-tooltip: 600;
}Motion tokens
| Token | Value | Use |
|---|---|---|
| duration-instant | 100ms | Hover, colour changes |
| duration-fast | 150ms | Toggles, small state changes |
| duration-base | 240ms | Dropdowns, expanding content |
| duration-slow | 400ms | Large transitions, sheets |
| ease-standard | cubic-bezier(0.4, 0, 0.2, 1) | Moving within the screen |
| ease-enter | cubic-bezier(0, 0, 0.2, 1) | Elements entering |
| ease-exit | cubic-bezier(0.4, 0, 1, 1) | Elements leaving |
Logical properties and RTL
If your products support right-to-left languages like Arabic, build the foundations with logical properties from the start. Instead of left/right, use start/end, so layouts mirror automatically when dir="rtl".
| Physical (avoid) | Logical (prefer) |
|---|---|
| margin-left | margin-inline-start |
| padding-right | padding-inline-end |
| left: 0 | inset-inline-start: 0 |
| text-align: left | text-align: start |
| border-left | border-inline-start |
Common mistake: Designing tokens and components for left-to-right only and "adding RTL later". Retrofitting mirrored layouts across a whole system is far more work than using logical properties from day one.
Key takeaways
- A 4/8-point spacing scale removes guesswork; semantic spacing tokens add intent and density options.
- Define grids, breakpoints, max widths and layout components.
- Standardise sizes, radius, borders, shadows, z-index layers and motion as tokens.
- Outer radius = inner radius + padding keeps nested corners harmonious.
- Use logical properties (start/end) so the whole system supports RTL.
Exercise
Write the foundations file
- Create spacing, radius, sizing, shadow, z-index and motion tokens as CSS variables.
- Create matching Figma variables for spacing and radius.
- Build a card, a button and an input using only these tokens.
- Rewrite any left/right CSS with logical properties.
- Switch the page to dir="rtl" and check that everything mirrors correctly.
Test yourself
Spacing, layout & other foundations quiz
5 questions. Score 70% or more to complete the lesson.
