Shadows
- Create depth and elevation effects using box-shadow and modern UI shadow utilities.
What is a Box Shadow in UI Design ?
A box shadow creates the illusion that an element is:
Elevated above the surface
Separated from the background
Interactive or important
In modern interfaces, shadows help users understand:
What is clickable
What is layered
What is currently in focus
Shadows are not added for beauty alone - they communicate depth and hierarchy.
In Tailwind CSS, shadows are treated as a consistent elevation scale, not random visual effects.
Shadows vs Borders (Important Distinction)
Aspect Border Shadow Purpose Separation Elevation Flat UI Yes No Indicates clickability Sometimes Yes Depth perception No Yes Rule to remember:
Borders define structure
Shadows define elevation
They should complement each other, not compete.
Tailwind Box Shadow Utilities
Tailwind provides a predefined shadow scale:
shadow-none
shadow-sm
shadow
shadow-md
shadow-lg
shadow-xl
shadow-2xl
shadow-inner
These shadows are carefully designed to:
Feel natural
Scale gradually
Work across light and dark backgrounds
Understanding the Shadow Scale
Think of shadows as layers above the surface.
Low Elevation Shadow
Applies a small shadow to create subtle elevation above the background.
<div class="shadow-sm p-4 bg-white">
Low elevation card
</div>
Use for:
Subtle cards
Input fields
Static containers
Feels:
Light
Minimal
Calm
Interactive Card with Elevation
Uses a medium shadow to visually lift interactive elements like cards above the background.
<div class="shadow-md p-4 bg-white">
Interactive card
</div>
Use for:
Clickable cards
Dropdowns
Buttons
Panels
Feels:
Interactive
Clearly separated
Balanced
Floating Panel with Strong Shadow
Uses a large shadow to create strong elevation, making panels appear lifted above the interface.
<div class="shadow-lg p-6 bg-white">
Floating panel
</div>
Use for:
Modals
Popovers
Overlays
Floating menus
Feels:
Prominent
Focused
Important
Avoid using high elevation everywhere.
Shadow Hierarchy
A good UI has multiple shadow levels, not one.
Example hierarchy:
Page background → no shadow
Cards → shadow-sm
Dropdowns → shadow-md
Modals → shadow-xl
This creates:
Clear depth
Natural stacking
Visual logic
If everything has the same shadow, depth is lost.
Hover Elevation Effect
Increases shadow on hover to provide visual feedback and emphasize interactivity.
<div class="shadow-sm hover:shadow-md transition-shadow duration-200">
Hoverable card
</div>
Why this works:
Hover increases elevation
Signals interactivity
Feels responsive and modern
This is a very common real-world pattern.
Shadows in Dark Mode
Shadows behave differently on dark backgrounds.
Problem:
Dark shadows disappear on dark surfaces
Solution:
Use softer, larger shadows
Combine with background contrast
Shadows in Dark Mode
Uses darker, diffused shadows in dark mode to maintain visible elevation on dark surfaces.
<div class="bg-slate-800 shadow-lg dark:shadow-black/40">
</div>
Dark mode shadows should:
Be subtle
Suggest separation
Not rely on pure black
Inner Shadow
This Tailwind CSS code uses shadow-inner to create an inset shadow effect.
<div class="shadow-inner p-4 bg-gray-100">
Pressed or inset element
</div>
Used for:
Pressed buttons
Inset panels
Input fields (rare)
Inner shadows should be used very sparingly.
Shadows vs Opacity vs Blur
Do not confuse these concepts:
Shadow → elevation
Opacity → emphasis/state
Blur → background separation
Shadows should not be replaced with opacity tricks.
Accessibility & Shadows
Shadows improve accessibility when they:
Clarify interactive elements
Distinguish layers
Support focus states
But avoid:
Using shadow as the only indicator
Low-contrast shadows that disappear
Overuse that creates confusion
Always pair shadows with:
Clear structure
Proper spacing
Visible focus styles
Common Mistakes
Using large shadows everywhere
Mixing different shadow levels randomly
Using shadows instead of layout spacing
Ignoring dark mode behavior
Adding shadows just for decoration
If UI feels “heavy” or “messy”, shadows are likely overused.
Shadow Design Rules
Start with no shadow
Add shadows only where elevation is needed
Use the smallest shadow that works
Maintain a clear elevation hierarchy
Test shadows in light and dark mode
Be consistent across components
Shadows should feel natural and quiet, not loud.
Card Shadow Hover
Creates a card with a hover shadow effect.
<div class="bg-white rounded-lg shadow-sm hover:shadow-md transition-shadow">
<h3 class="font-semibold text-lg">
Card Title
</h3>
<p class="text-gray-600">
Subtle elevation with interaction feedback.
</p>
</div>