CSS Shadow Generator: Stacking Multiple box-shadow Layers

Open Tool Box Shadow Generator

One layer is not enough

Real shadows combine multiple light sources and occlusion, while a single box-shadow offers only offset, blur, spread and colour — always reading like a sticker. Layers fix this: a small dark contact shadow anchoring the object, plus a wide faint ambient shadow conveying height. The tool adds and deletes layers, each with independent parameters, emitting one comma-separated declaration.

Steps

  1. Add a layer for the contact shadow: two to four pixels offset, four to eight blur, moderate alpha.
  2. Add an ambient layer: teens to twenties offset, thirty-plus blur, very low alpha.
  3. Adjust horizontal and vertical offset, blur, spread, colour and inset per layer.
  4. Delete excess layers, reset defaults, or load the two-layer example.
  5. Copy code, remembering earlier layers paint on top.

What the numbers mean

Offsets set light direction; both positive places light upper left with shadow lower right, the usual convention. Blur approximates Gaussian standard deviation rather than transition length, so larger values soften edges. Spread scales the shadow outward or inward, where negative values trace thin edges. Avoid pure black: a low-alpha deep blue or violet reads more naturally, while black looks dirty.

Layers and believability

Contact shadows stay small, dark and nearly sharp to express contact; ambient shadows stay large, pale and very soft to express height. Mismatched proportions betray the illusion — an oversized contact shadow floats, an over-dark ambient smudges. Hover states can add a faint middle layer. Direction must stay consistent sitewide, or the whole page feels unmoored. Dark mode needs raised surface colours or hairline borders instead, since shadows vanish.

Common problems

Five or more layers produce long strings and real paint cost, dropping frames while scrolling on mobile. Mixing inset and outset cancels meaning, one carving, the other lifting. An overflow-hidden ancestor clips shadows. clip-path cuts them too. And large blurred shadows are expensive on weak hardware, especially dozens of cards in a list.

⏫︎