Skip to content
NewTemplates & toolkits are on the way — join the waitlist
Hecham Gazhi

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.

TokenValueCommon use
space-00Reset
space-14pxIcon to text, tight gaps
space-28pxInside small components, between related items
space-312pxInput padding, list item gaps
space-416pxCard padding (mobile), default gap
space-624pxCard padding, gaps between groups
space-832pxBetween sections inside a page
space-1248pxBetween major sections
space-1664pxPage sections on desktop
space-2496pxLarge marketing sections

Live preview

space-1 · 4px
space-2 · 8px
space-3 · 12px
space-4 · 16px
space-6 · 24px
space-8 · 32px
space-12 · 48px
space-16 · 64px

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.

Examplecss
: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 tokenMin widthColumnsMarginGutter
bp-sm0416px16px
bp-md640px824px16px
bp-lg1024px1232px24px
bp-xl1280px12auto (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

TokenValueUse
radius-none0Tables, full-bleed images
radius-sm4pxBadges, small controls
radius-md8pxButtons, inputs, cards
radius-lg16pxModals, sheets, large cards
radius-full9999pxPills, avatars, toggles
border-width-default1pxInputs, cards, dividers
border-width-strong2pxFocus rings, selected states
shadow-1 / 2 / 3Layered shadowsRaised, 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:

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

TokenValueUse
duration-instant100msHover, colour changes
duration-fast150msToggles, small state changes
duration-base240msDropdowns, expanding content
duration-slow400msLarge transitions, sheets
ease-standardcubic-bezier(0.4, 0, 0.2, 1)Moving within the screen
ease-entercubic-bezier(0, 0, 0.2, 1)Elements entering
ease-exitcubic-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-leftmargin-inline-start
padding-rightpadding-inline-end
left: 0inset-inline-start: 0
text-align: lefttext-align: start
border-leftborder-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

  1. Create spacing, radius, sizing, shadow, z-index and motion tokens as CSS variables.
  2. Create matching Figma variables for spacing and radius.
  3. Build a card, a button and an input using only these tokens.
  4. Rewrite any left/right CSS with logical properties.
  5. 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.

  1. 1.Which set is a typical 8-point spacing scale?
  2. 2.Why share control heights (32/40/48px) across buttons, inputs and selects?
  3. 3.Why define named z-index layers?
  4. 4.A card has 16px radius and 8px padding. What radius should an image inside it have?
  5. 5.Why prefer margin-inline-start over margin-left?