← Back to Projects
UI Depth System - Professional three-tier shadow system
showcaseAdvancedView Demo →

UI Depth System Integration

Professional three-tier shadow system with theme-aware elevation for Next.js portfolio

Scroll to explore
Built with:Next.js 15Tailwind CSS 4.0TypeScriptOKLCH
Light mode depth system demonstration

OKLCH Color Space Excellence

Leverages OKLCH color space for perceptually uniform shadows that adapt seamlessly between light and dark themes. Achieves WCAG AAA contrast compliance with 15:1 in light mode and 20:1 in dark mode, ensuring superior accessibility and color fidelity across all devices.

15:1
Light Contrast
20:1
Dark Contrast
Dark mode depth system with highlights

Three-Tier Professional System

Industry-standard depth hierarchy following best practices from Vercel, Stripe, and Shopify. Small shadows for subtle navigation, medium for interactive cards and buttons, large for modals and floating panels, plus inset shadows for pressed states. All semantic and theme-aware.

4
Shadow Tiers
30+
Components Updated
Component depth system integration

Zero-JavaScript Pure CSS

Built entirely with CSS custom properties for zero runtime overhead. Automatic theme adaptation, smooth transitions, and no hydration issues. CSS bundle increase under 2KB gzipped while providing professional depth across all components with semantic Tailwind utilities.

<2KB
CSS Overhead
0ms
Runtime Cost
0%
Performance
0%
Accessibility
0%
Best Practices
0%
SEO
0
Jest Tests
0
E2E Tests
38s
Build Time
136KB
Max Bundle
0
Lines of Code
0
Components
0
Pages
0
Total Tests

Gallery

0%

Swipe to scroll • Tap to view fullscreen

Development Process

Follow the journey from concept to completion

Phase 1
2 days

Foundation Setup

Created CSS variable system with OKLCH color space, built visual demo page, validated zero impact on existing pages, and verified CSS bundle stayed under 2KB increase.

Phase 2
3 days

Theme System Migration

Migrated 30+ components to theme-aware CSS variables, fixed hydration flash with blocking script, implemented device-specific theme toggle, and achieved WCAG AAA contrast compliance.

Phase 3
2 days

Professional Tailwind Utilities

Created semantic utility classes following industry standards, migrated all arbitrary shadow values, updated card/button/navigation components, and wrote comprehensive documentation.

Phase 4
1 day

Polish & Enhancement

Enhanced navigation with subtle depth separation, added floating effect to hero avatar, improved easter egg with device-specific activation, and validated scroll behavior.

Phase 5
2 days

Testing & Validation

Passed 162 Jest tests and 175 Playwright E2E tests, validated keyboard navigation, verified color contrast ratios, and ensured production build succeeded with zero errors.

Phase 6
2 days

Documentation & Production

Created 4 comprehensive developer guides totaling 11,000+ words, updated README and content management docs, completed production build, and passed code quality review.

Project Complete

All phases successfully executed

Project Resources

Topics

CSSTailwindNext.jsTypeScriptDesign System

UI Depth System Integration

A complete, production-ready implementation of a professional UI depth system with automatic light/dark theme adaptation. Built with modern CSS custom properties and OKLCH color space for superior color fidelity.

🎯 The Challenge

Modern portfolios often feel flat and lack visual hierarchy. Users struggle to distinguish interactive elements from static content, especially when switching between light and dark modes. Traditional shadow implementations either:

  • Break when themes change (hardcoded colors)
  • Look inconsistent across components
  • Require manual updates for every element
  • Don't follow design system best practices

✨ The Solution

A three-tier professional depth system following industry standards (Vercel, Stripe, Shopify approach):

Depth Tiers

  • Small Shadows - Subtle elevation for navigation, cards, subtle separators
  • Medium Shadows - Standard elevation for buttons, project cards, interactive elements
  • Large Shadows - Prominent elevation for modals, dropdowns, floating panels
  • Inset Shadows - Pressed/active states for buttons and interactive elements

Theme Intelligence

Uses OKLCH color space for:

  • Automatic adaptation to light/dark themes
  • Perceptually uniform color transitions
  • Better color fidelity across devices
  • WCAG AAA contrast compliance (15:1 light, 20:1 dark)

🛠️ Technical Implementation

CSS Architecture

Built entirely with CSS custom properties for zero JavaScript overhead:

/* Core depth variables using OKLCH */
:root {
  /* Light theme shadows */
  --shadow-s: 0 1px 2px oklch(0% 0 0 / 0.08);
  --shadow-m: 0 4px 12px oklch(0% 0 0 / 0.12);
  --shadow-l: 0 12px 32px oklch(0% 0 0 / 0.18);
}

.dark {
  /* Dark theme shadows with highlights */
  --shadow-s: 0 1px 2px oklch(0% 0 0 / 0.4),
              0 0 1px oklch(100% 0 0 / 0.06);
  --shadow-m: 0 4px 12px oklch(0% 0 0 / 0.5),
              0 0 2px oklch(100% 0 0 / 0.08);
  --shadow-l: 0 12px 32px oklch(0% 0 0 / 0.6),
              0 0 4px oklch(100% 0 0 / 0.1);
}

Professional Tailwind Utilities

Created semantic utility classes for consistent application:

// Small shadow (navigation, subtle elements)
<nav className="shadow-depth-s">

// Medium shadow (cards, buttons)
<button className="shadow-depth-m hover:shadow-depth-l">

// Large shadow (modals, dropdowns)
<div className="shadow-depth-l">

// Inset (pressed states)
<button className="active:shadow-depth-inset">

Component Integration

Updated 30+ components to use the depth system:

// Before (hardcoded, theme-unaware)
<div className="shadow-[0_4px_12px_rgba(0,0,0,0.1)]">

// After (semantic, theme-aware)
<div className="shadow-depth-m">

📊 Implementation Phases

Phase 1: Foundation Setup

  • Created CSS variable system with OKLCH color space
  • Built visual demo page (/depth-demo)
  • Validated zero impact on existing pages
  • Verified CSS bundle <2KB increase

Phase 2: Theme System Migration

  • Migrated 30+ components to theme-aware CSS variables
  • Fixed hydration flash with blocking script
  • Implemented device-specific theme toggle (Cmd+Click desktop, triple-tap mobile)
  • Achieved WCAG AAA contrast compliance

Phase 3: Professional Tailwind Utilities

  • Created semantic utility classes following industry standards
  • Migrated all arbitrary shadow values to utilities
  • Updated card, button, navigation, hero, footer components
  • Comprehensive documentation (11,000+ words)

Phase 4: Polish & Enhancement

  • Enhanced navigation with subtle depth separation
  • Added floating effect to hero avatar
  • Improved easter egg with device-specific activation
  • Validated scroll behavior and performance

Phase 5: Testing & Validation

  • 162 Jest tests passing
  • 175 Playwright E2E tests passing
  • Keyboard navigation validated
  • Color contrast verified (15:1 light, 20:1 dark)

Phase 6: Documentation & Production

  • Created 4 comprehensive developer guides
  • Updated README and content management docs
  • Production build successful (0 errors, 0 warnings, 21 pages)
  • Code quality review passed

🎨 Visual Impact

Before

  • Flat UI with no depth hierarchy
  • Dark mode only with hardcoded colors
  • Inconsistent shadow implementation
  • Theme toggle broken (white text on white in light mode)

After

  • Professional three-tier depth system
  • Full light/dark mode support
  • Semantic shadow utilities throughout
  • Smooth theme transitions with device-specific activation
  • Clear visual hierarchy and component separation

🧪 Testing Results

Automated Testing

162 Jest tests - All passing (0 failures)
175 Playwright E2E tests - All passing
TypeScript compilation - Zero errors
Production build - 0 errors, 0 warnings, 21 pages

Performance Metrics

CSS bundle size: <2KB gzipped increase (target met)
First Load JS: 101-136 kB (excellent)
Zero runtime overhead: Pure CSS implementation
No hydration errors: Fixed with blocking script

Accessibility

Keyboard navigation - All interactive elements accessible
Color contrast - WCAG AAA (15:1 light, 20:1 dark)
Theme transitions - Smooth, no flickering

📚 Documentation Created

  1. DEPTH_SYSTEM_UTILITIES.md (8,946 bytes)

    • Complete developer guide with code examples
    • Shadow tier documentation and best practices
    • Layer system variables reference
    • Troubleshooting and browser compatibility
  2. DEPTH_SYSTEM_QUICK_REFERENCE.md (1,178 bytes)

    • Quick lookup for developers
    • Shadow class cheat sheet
    • Common usage patterns
  3. DEPTH_SYSTEM_MIGRATION_COMPLETE.md (7,491 bytes)

    • Migration summary and sign-off
    • Implementation timeline
    • Testing results and validation
  4. MANUAL_TESTING_GUIDE.md (763 lines)

    • Step-by-step manual testing procedures
    • Accessibility audit workflows
    • Cross-browser testing checklists
  5. Content Creator Documentation

    • Added depth system section to CONTENT_MANAGEMENT.md
    • Explains when content creators should care
    • Provides HTML examples for advanced users

🚀 Impact & Results

Developer Experience

  • Semantic utilities make depth application intuitive
  • Zero JavaScript overhead improves performance
  • Theme-aware shadows eliminate manual updates
  • Comprehensive docs reduce onboarding time

User Experience

  • Visual hierarchy guides attention naturally
  • Smooth transitions between light/dark modes
  • Device-specific theme toggle prevents confusion
  • Accessibility ensures all users can interact

Production Ready

  • Zero errors in production build
  • All tests passing (337 total tests)
  • Documentation complete (11,000+ words)
  • Code quality validated across all components

💡 Key Learnings

Technical Insights

  1. OKLCH superiority: Perceptually uniform color space provides better theme transitions than RGB/HSL
  2. CSS custom properties: Provide theme awareness with zero JavaScript
  3. Semantic naming: Utility classes like shadow-depth-m are more maintainable than arbitrary values
  4. Blocking scripts: Essential for preventing theme flash on initial load

Process Insights

  1. Phased approach: Breaking implementation into 6 phases prevented scope creep
  2. Documentation first: Writing docs as you go ensures accuracy
  3. Testing continuously: Running tests throughout prevents regression surprises
  4. Demo pages: Visual validation pages catch issues automated tests miss

Design Insights

  1. Subtlety wins: Small shadows (depth-s) are often more effective than large ones
  2. Dark mode needs highlights: Subtle light borders prevent elements from looking "sunk"
  3. Context matters: Same shadow tier looks different on light vs dark backgrounds
  4. Device context: Desktop users expect modifier keys (Cmd/Ctrl), mobile users expect taps

🔮 What's Next

Potential Enhancements

  • Light mode polish: Aesthetic refinement tracked in prd-lighthouse-optimization.md
  • Animation variants: Smooth shadow transitions on hover/focus
  • Additional tiers: Explore extra-large shadows for hero elements
  • Color variants: Brand-colored shadows for category-specific elements

Broader Applications

  • Component library: Package as standalone NPM module
  • Design tokens: Export to Figma/Sketch for design consistency
  • Documentation site: Create interactive depth system playground
  • Teaching resource: Write tutorial series on modern CSS techniques

🎯 Success Criteria Met

Performance: CSS bundle <2KB increase (met: ~1.8KB gzipped)
Testing: All tests passing (162 Jest + 175 E2E)
Accessibility: WCAG AAA contrast (15:1 light, 20:1 dark)
Documentation: Comprehensive guides (11,000+ words)
Code Quality: Zero console.logs, proper TypeScript, clean formatting
Production Build: 0 errors, 0 warnings
Theme System: Full light/dark mode support
Visual Hierarchy: Clear depth and elevation throughout UI

🌟 Try It Live

Demo Page: Visit /depth-demo to see all shadow tiers in action
Theme Toggle: Cmd+Click "command the light" in footer (desktop) or triple-tap (mobile)
Source Code: Available on GitHub under feat/ui-depth-system branch


Built with ❤️ using Next.js, TypeScript, Tailwind CSS, and OKLCH color space

Like this project? Share it!

Share: