Free CSS Box Shadow Generator
The Box Shadow Generator helps you craft the perfect CSS box-shadow with live preview. Tweak offset, blur, spread, color, and inset, then copy the ready-to-use CSS.
Shadow work sits alongside the CSS Border Radius Generator and the Glassmorphism CSS Generator, which combine the same properties. To check the contrast of the shadowed surface, the Color Contrast Checker is the verification step.
How to use the Box Shadow
- 1 Set the horizontal and vertical offsets with the sliders, or type exact values.
- 2 Adjust the blur radius. A larger blur softens the edge; the spread value expands or contracts the shadow before blurring.
- 3 Pick a colour and reduce the opacity — a shadow at full opacity looks like a second element rather than a shadow.
- 4 Copy the generated `box-shadow` declaration, or add layered shadows for a more realistic result.
Building a believable shadow
The give-away of a badly shadowed interface is uniformity: the same shadow on every element regardless of its size or elevation, and a shadow that is the same darkness everywhere. Real shadows vary with the distance between the object and the surface, becoming softer and lighter as that distance grows.
That suggests a small system rather than a single value. Two or three levels of elevation, each with a proportionally larger blur, lower opacity and greater offset, covers most interface needs and produces a consistent sense of depth.
- Offset downward more than sideways to imply light from above.
- Keep opacity low — 10 to 25 per cent is usually enough.
- Layer two or three shadows rather than using one.
- Animate the shadow's opacity, not its blur radius.
Frequently asked questions
What does the spread value do?
It expands or contracts the shadow's shape before the blur is applied. A positive spread makes the shadow larger than the element in every direction; a negative spread shrinks it. Negative spread with a large blur is how you produce a shadow that appears only at the bottom, rather than one bleeding out on all sides.
How do I make a shadow look realistic rather than like a grey box?
Use several layered shadows with increasing blur and decreasing opacity, and offset them downward more than sideways. Real light comes from above, so a shadow cast by ambient light is soft and wide directly below the object, with a tighter darker one close to the edge. A single hard shadow with a large offset reads as artificial.
Do shadows hurt performance?
A large blurred shadow is genuinely expensive to composite, more so than most people assume, and it is worse on elements that animate. Animating a shadow forces a repaint each frame. The common workaround is to render the shadow on a pseudo-element and animate its opacity instead, which the compositor can handle.
Related Developer Tools
You might also need
Tools from other categories that people pair with the Box Shadow: