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

UI Design · Lesson 10 / 12

Depth, shadows & dark mode

How to use elevation, shadows, borders and layering to show structure, how to design realistic shadows, and a complete guide to designing dark mode that is readable, accessible and on-brand.

5 min read · 5 quiz questions

Why depth matters

Screens are flat, but interfaces have layers: a page, cards on the page, a menu above the cards, a dialog above everything. Depth tells people what's on top, what belongs together, and what they can interact with.

Depth can be shown with shadows, borders, background colours, blur and overlap. Used consistently, it makes structure obvious. Used randomly, it adds noise.

Elevation levels

Define a small set of elevation levels and assign each component to one. Higher levels sit closer to the user and cast larger, softer shadows.

LevelComponentsShadow
0 — BasePage background, flat sectionsNone
1 — RaisedCards, list items, inputsVery subtle (or a border)
2 — OverlayDropdowns, popovers, sticky headersMedium, soft
3 — ModalDialogs, bottom sheets, drawersLarge, very soft, plus a dimmed backdrop
4 — ToastNotifications that float above everythingLarge

Live preview

0 · page
1 · card
2 · dropdown
3 · modal

Designing realistic shadows

  • Keep one light source, usually from above. Shadows fall downward (positive Y offset), not sideways.
  • Combine two shadows: a small, sharper one for contact and a larger, blurrier one for ambient light. This looks far more natural than a single shadow.
  • Use low opacity (5–20%) and a dark, slightly tinted colour instead of pure black.
  • Larger elevation = larger offset and blur, and slightly lower opacity.
Examplecss
:root {
  --shadow-1: 0 1px 2px rgb(15 15 13 / .06), 0 1px 3px rgb(15 15 13 / .10);
  --shadow-2: 0 2px 4px rgb(15 15 13 / .06), 0 8px 16px rgb(15 15 13 / .10);
  --shadow-3: 0 4px 8px rgb(15 15 13 / .06), 0 20px 48px rgb(15 15 13 / .18);
}
.card     { box-shadow: var(--shadow-1); }
.dropdown { box-shadow: var(--shadow-2); }
.dialog   { box-shadow: var(--shadow-3); }

Common mistake: Heavy, dark shadows on every card. They make an interface feel dated and muddy. Most cards need only a hairline border or a barely visible shadow.

Other ways to show depth

  • Borders — a 1px border in a light neutral is often cleaner than a shadow, especially in dense interfaces.
  • Background contrast — a white card on a light grey page is raised without any shadow.
  • Backdrop / scrim — a semi-transparent dark layer behind modals focuses attention (figure–ground).
  • Blur — a frosted background (backdrop-filter) separates layers; use sparingly and check text contrast.
  • Overlap — an element overlapping another is clearly in front of it.

Why dark mode?

Dark mode is a colour scheme with light text on dark backgrounds. Many people prefer it in low light; some find it more comfortable; on OLED screens it can save battery. Operating systems let users choose, and many expect apps to follow their system setting.

Dark mode is not simply inverting colours. It needs its own carefully chosen values.

Designing dark mode

Backgrounds

Avoid pure black (#000) for large areas. A very dark grey (e.g. #121212 as recommended by Material Design, or a dark tinted neutral) reduces harsh contrast and the smearing some people notice when scrolling on OLED screens, and leaves room to show elevation.

Elevation in the dark

Shadows are almost invisible on dark backgrounds. Instead, make higher surfaces lighter: base #121212, cards a little lighter, menus lighter still. Material Design does this with a white overlay of increasing opacity.

Text

Pure white text on near-black can feel glaring. Use off-white for body text (e.g. 87% white) and dimmer values for secondary text (60%) — while still meeting contrast requirements.

Colours

Saturated brand colours that look great on white can vibrate on dark backgrounds. Use lighter, slightly desaturated tints of your accent (e.g. blue-300 instead of blue-600) for text and icons, and re-check contrast.

Images and illustrations

Very bright images can be glaring; consider slightly reducing their brightness. Illustrations with white backgrounds need dark-mode versions or transparent backgrounds.

RoleLight modeDark mode
Background#FFFFFF#121212
Surface (card)#FFFFFF + shadow#1E1E1E
Surface (menu)#FFFFFF + larger shadow#2A2A2A
Text primary#0F0F0Drgba(255,255,255,.87)
Text secondary#6B6860rgba(255,255,255,.60)
Primary action#146EF5#6AA6FF
Border#E8E6E1rgba(255,255,255,.12)

Building themes with tokens

The cleanest way to support light and dark mode is with semantic colour tokens. Components use names like surface and text-primary; each theme maps those names to different values. You redesign the mapping once instead of every screen.

Do

  • Follow the user's system setting by default and offer a manual switch.
  • Use semantic tokens for every colour.
  • Show elevation with lighter surfaces in dark mode.
  • Re-check contrast for every text and icon colour.

Don't

  • Invert colours automatically.
  • Use pure black backgrounds with pure white text everywhere.
  • Reuse saturated light-mode accents unchanged.
  • Forget images, illustrations, charts and logos.
Examplecss
:root {
  --surface: #ffffff;
  --text-primary: #0f0f0d;
  --action: #146ef5;
}
@media (prefers-color-scheme: dark) {
  :root {
    --surface: #121212;
    --text-primary: rgb(255 255 255 / .87);
    --action: #6aa6ff;
  }
}
.card { background: var(--surface); color: var(--text-primary); }

Key takeaways

  • Depth shows layers: base, raised, overlay, modal — define a few elevation levels and reuse them.
  • Realistic shadows use one light source, two layered shadows and low opacity.
  • Borders, background contrast, scrims and overlap can show depth without heavy shadows.
  • Dark mode needs its own palette: dark grey surfaces, lighter surfaces for higher elevation, off-white text, lighter accents.
  • Semantic tokens make theming possible — and contrast must be checked in both modes.

Exercise

Create light and dark themes

  1. Design a screen with a page background, two cards, a dropdown and a modal.
  2. Define 4 elevation levels and apply them.
  3. Create semantic colour variables in Figma with Light and Dark modes.
  4. Switch the screen to dark mode and adjust surfaces so elevation is still clear.
  5. Check contrast of every text colour in both modes.

Test yourself

Depth, shadows & dark mode quiz

5 questions. Score 70% or more to complete the lesson.

  1. 1.A modal should appear at…
  2. 2.Why combine two shadows on one element?
  3. 3.In dark mode, how is elevation usually shown?
  4. 4.Why avoid pure white text on pure black?
  5. 5.What makes switching between light and dark themes manageable?