CSS Box Shadow Generator

Box Preview
0px
10px
25px
-5px
15%
Preview Environment Settings

Mastering Depth & Elevation in Web UI Design with CSS Box Shadows

In modern user interface design, visual hierarchy and spatial depth are achieved using elevation layers. The CSS box-shadow property casts soft or sharp shadow effects around an element's frame, giving buttons, cards, modal dialogs, and navigation bars a realistic 3D appearance above the page canvas.

Understanding CSS Box Shadow Syntax

A standard CSS box-shadow declaration consists of up to six parameters:

box-shadow: [inset] <offset-x> <offset-y> <blur-radius> <spread-radius> <color>;

Box Shadow Parameter Breakdown

  • Horizontal Offset (X) Determines the horizontal shadow distance. Positive values cast the shadow to the right; negative values cast it to the left.
  • Vertical Offset (Y) Determines the vertical shadow distance. Positive values cast the shadow downward; negative values cast it upward.
  • Blur Radius Controls shadow softness. Higher values create larger, softer, more diffuse shadows. Setting blur to 0px creates a sharp, solid shadow edge.
  • Spread Radius Expands or shrinks the shadow size relative to the box dimensions. Positive values expand the shadow outwards; negative values contract it.
  • Inset Keyword Changes the shadow from an outer drop-shadow to an inner shadow cast inside the element frame (ideal for pressed button states or form inputs).

Best Practices for Professional Shadows

Use Low Opacity RGBA Colors

Avoid heavy, pure black shadows (rgba(0,0,0,1)). Soft shadows with low opacity (10% to 20%) look significantly more realistic and modern.

Negative Spread for Lifted Elevation

Applying a small negative spread radius (e.g. spread: -5px) prevents shadows from extending awkwardly sideways, creating a cleaner floating card effect.