Home
Bookmarks
Leagues
LEARN
Courses
Career Paths
Assessments
Tutorials
Arcade
Glossary
GROW
Certifications
Log in
Glossary
Log inSign up
Courses/Introduction to Design Systems/Elevation, Z-Index & Spatial Depth
Level 4 · Component Architecture & Visual Language

Elevation, Z-Index & Spatial Depth

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 Physical Model of Digital ElevationMulti-Layer Shadows: Ambient + Directional LightThe 5 Systemic Elevation TiersElevation in Dark Mode: Surface Tints Over ShadowsTokenizing Z-Index: Ending the `z-index: 999999` NightmareStacking Context Traps in CSSMotion & Elevation: Hover Lifts and TransitionsGlassmorphism & Frosted Backdrops (`backdrop-filter`)Challenge: Resolving a Complex Z-Index & Overlay Collision

From Course

📘
Introduction to Design SystemsBeginner · 16 lessons
Elevation, Z-Index & Spatial Depth

Lesson

Elevation, Z-Index & Spatial Depth

The Physical Model of Digital ElevationMulti-Layer Shadows: Ambient + Directional LightThe 5 Systemic Elevation TiersElevation in Dark Mode: Surface Tints Over ShadowsTokenizing Z-Index: Ending the `z-index: 999999` NightmareStacking Context Traps in CSSMotion & Elevation: Hover Lifts and TransitionsGlassmorphism & Frosted Backdrops (`backdrop-filter`)Challenge: Resolving a Complex Z-Index & Overlay Collision
Unlock lesson
Complete lesson and earn 250 PX
Exercise #1

The Physical Model of Digital Elevation

Digital screens are physically flat, two-dimensional surfaces. Yet, users interact with interfaces as though they possess physical depth: dialogs float above pages, dropdowns hover over tables, and buttons depress when clicked.

We create this illusion of three-dimensional depth using Elevation:

  • In the physical world, an overhead light source casts shadows based on how close an object is to the surface.
  • An object resting flat on a desk casts a tight, sharp, dark shadow.
  • As the object rises higher into the air (closer to the light source), its shadow becomes larger, softer, more blurred, and lower in contrast.

Understanding this physical relationship allows design systems to establish realistic, harmonious elevation tokens.

Exercise #2

Multi-Layer Shadows: Ambient + Directional Light

A single, harsh CSS drop shadow like box-shadow: 0 10px 20px rgba(0,0,0,0.4) looks cheap, muddy, and unnatural. In real life, light bounces off nearby walls and surfaces, creating two simultaneous shadows:

  1. The Ambient Shadow: Soft, dispersed, omnidirectional light with zero vertical offset and low opacity.
  2. The Key / Directional Shadow: A sharper, downward-offset shadow cast by the primary directional light source.

Professional design systems combine these into multi-layer shadow tokens:

--elevation-card: 
  0 1px 3px rgba(0, 0, 0, 0.05),     /* Ambient shadow */
  0 4px 12px rgba(0, 0, 0, 0.08);    /* Directional key shadow */

Multi-layering produces buttery smooth, realistic depth that elevates the entire aesthetic of your product.

Exercise #3

The 5 Systemic Elevation Tiers

To keep interfaces calm and uncluttered, a design system defines five distinct elevation tiers:

  • Elevation 0 (Flat / Base Canvas): The resting background surface (#090D16). Table rows, flat list items, and resting containers live here.
  • Elevation 1 (Raised / Cards): Low elevation (0 1px 3px ...). Interactive cards, panels, and widgets. Provides subtle separation from the canvas.
  • Elevation 2 (Floating / Overlays): Medium elevation (0 4px 12px ...). Dropdown menus, tooltips, and floating action buttons.
  • Elevation 3 (Overlay / Modals): High elevation (0 12px 32px ...). Modal dialogs, side sheets, and full-screen drawers that interrupt user workflows.
  • Elevation 4 (System Sticky / Toasts): Topmost tier. Notification snackbars, system alerts, and persistent sticky headers.
Exercise #4

Elevation in Dark Mode: Surface Tints Over Shadows

In light mode, black drop shadows contrast vividly against white canvases. In dark mode, however, a black shadow cast against a dark charcoal background (#0B0F19) is virtually invisible.

The Dark Mode Elevation Formula: Instead of relying solely on shadows, dark interfaces express elevation through luminosity and border highlights:

  1. Lighter Surface Colors: Each elevation tier receives a slightly lighter background tint (e.g., Level 0 = #0B0F19, Level 1 = #151C2C, Level 2 = #1E293B, Level 3 = #2C3A54).
  2. Subtle White Border Highlights: A 1px border with 6–10% white opacity (border: 1px solid rgba(255, 255, 255, 0.08)) creates a crisp specular highlight that outlines the elevated boundary.
  3. Deep Ambient Glow: In dark mode, shadows act as dark occlusions rather than black shapes.
Exercise #5

Tokenizing Z-Index: Ending the `z-index: 999999` Nightmare

Every web developer has encountered this disaster: an engineer wants a modal to sit on top of a sticky header, so they write z-index: 999. Another engineer wants a toast to sit on top of the modal, so they write z-index: 999999. Soon, the codebase is an unmaintainable war of arbitrary numbers.

A design system ends this chaos with a strict, tokenized Z-Index scale:

  • z-index-base: 0 (Standard document flow)
  • z-index-dropdown: 100 (Dropdown menus, autocomplete popovers)
  • z-index-sticky: 200 (Sticky navigation bars, fixed headers)
  • z-index-backdrop: 400 (Modal backdrop dimming overlay)
  • z-index-modal: 500 (Modal dialogs, side drawers)
  • z-index-toast: 1000 (Global system notifications, toasts)

By banning arbitrary z-index numbers and enforcing tokens via linters, UI elements layer in predictable, perfect order.

Exercise #6

Stacking Context Traps in CSS

Have you ever set z-index: 9999 on a tooltip, but it still rendered underneath a neighboring card? This occurs because of a CSS Stacking Context.

In CSS, z-index values are not global; they only compete against elements within the same stacking context. If a parent container creates a new stacking context, all its children are trapped inside it.

Common CSS properties that unintentionally trigger a new Stacking Context:

  • transform (e.g., transform: translate(0, 0) or scale(1.02) on card hover)
  • opacity less than 1 (e.g., opacity: 0.99)
  • filter (e.g., backdrop-filter: blur(8px))
  • will-change (e.g., will-change: transform)

The Design System Solution: React Portals Floating elements (tooltips, modals, dropdowns) should render via a Portal directly into document.body at the root level, bypassing all parent stacking contexts entirely.

Exercise #7

Motion & Elevation: Hover Lifts and Transitions

Elevation is dynamic. When a user hovers over an interactive card or presses a button, the element should feel responsive and alive.

The Physics of Hover Elevation:

  • Resting State: Elevation 1 (--elevation-card, transform: translateY(0)).
  • Hover State: Elevation 2 (--elevation-card-hover, transform: translateY(-2px)).
  • Transition Timing: Use a quick, natural spring or ease-out curve (transition: all 180ms cubic-bezier(0.16, 1, 0.3, 1)).

Notice that moving up 2px (translateY(-2px)) visually reinforces the expanding shadow: the object physically rises off the page toward the user's eye.

Exercise #8

Glassmorphism & Frosted Backdrops (`backdrop-filter`)

Modern operating systems (macOS Tahoe/Sonoma, iOS, Windows Fluent) use frosted glass materials to create subtle depth without completely obscuring background context.

In web design systems, this is achieved using backdrop-filter: blur():

.sticky-header {
  background-color: rgba(11, 15, 25, 0.8);
  backdrop-filter: blur(12px) saturate(160%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
  • Translucent Fill: 70–85% opacity allows content scrolling behind to peek through.
  • Blur & Saturation: blur(12px) softens underlying text so it doesn't distract; saturate(160%) prevents muddy grayish tones.
  • Fallback: Always supply a solid background fallback for older browsers or low-power modes.
Exercise #9

Challenge: Resolving a Complex Z-Index & Overlay Collision

Consider this real-world bug reported in a production app:

  • A user opens an account settings modal (z-index: 500).
  • Inside the modal, the user clicks a country selector dropdown.
  • However, the sticky marketing announcement bar at the top of the screen (z-index: 1000) renders on top of the modal's backdrop and cuts off the country dropdown!

The Root Cause: The marketing squad hardcoded z-index: 1000 on their sticky banner, which should have been z-sticky: 200.

The Systemic Fix:

  1. Re-map the sticky banner to --z-sticky (200).
  2. The modal overlay remains at --z-modal (500), naturally covering the sticky banner.
  3. The country dropdown is rendered via a Portal inside the modal's stacking context at --z-dropdown (600 within the modal tier), layering cleanly on top.