Why Flat UIs Feel Boring
Flat design is clean, but taken too far it becomes lifeless. Everything sits on the same plane, nothing stands out, and the interface feels like a spreadsheet.
Depth solves this by mimicking how the real world works: objects at different distances have different brightness, shadows, and clarity. In UI terms, this means creating layers — a background, a surface, and elevated elements — each slightly different in color.
3-4 Shades of the Same Color
The foundation of depth is having multiple shades of your background color. Pick one hue (or go neutral) and create 3-4 lightness steps: 5% for the deepest background, 10% for cards, 15% for elevated surfaces, and 20% for popovers or tooltips.
The key insight: lighter means elevated. Lighter means more important. This creates a natural hierarchy without borders or shadows — the shade alone communicates depth level.
:root {
--layer-1: hsla(220, 10%, 5%, 1);
--layer-2: hsla(220, 10%, 13%, 1);
--layer-3: hsla(220, 10%, 22%, 1);
--layer-4: hsla(220, 10%, 30%, 1);
--shadow: 0 6px 12px 0px hsla(220, 20%, 2%, 0.35000000000000003), 0 3px 4px 0px hsla(220, 30%, 1%, 0.45);
}Use 3-4 shades of the same hue for layers. Lighter = elevated = important. Combine a small dark shadow with a larger diffuse one for realistic depth.
The Two-Shadow Technique
Realistic shadows use two layers: a small, dark, tight shadow (simulates the contact point) combined with a larger, softer, lighter shadow (simulates ambient occlusion).
For example: 0 2px 4px rgba(0,0,0,0.3) plus 0 8px 24px rgba(0,0,0,0.15). The first creates crispness, the second creates atmosphere. Together they look far more natural than a single shadow.
For dark UIs, shadows need to be much darker to be visible — use 0.2-0.4 alpha instead of the 0.05-0.15 you'd use on light backgrounds.
Highlights and Inset Shadows
The secret sauce of polished UIs: a subtle top highlight. Add a 1px highlight or a gradient from white/4% to transparent along the top edge of elevated elements. This simulates light hitting the raised surface from above.
Inset shadows work the opposite way — they make elements feel recessed, like inputs, wells, or deactivated states. Use inset 0 2px 4px rgba(0,0,0,0.2) for a subtle pressed-in effect.
Key Takeaways
Related Guides & Tools
The Golden Rule: Don't Make Me Think
Master the principles of effortless, convention-driven UI design.
GuideWeb Animations That Actually Matter
Master CSS transitions, timing functions, and animations that improve UX.
GuideThe Easy Way to Pick Right Spacing
Master rem-based spacing for consistent, beautiful layouts.
GuideTypography: The 80% of UI Design
Master type scales, weight, and color — the fundamentals of UI typography.
GuideHow to Pick the Right Colors for UI
Learn the HSL color system, build full palettes, and master dark/light mode.
Want the full picture?
This free tool checks one slice of UX.
Picopi audits your entire page — issues, screenshots, and fixes — web or mobile.