Box shadow generator
Generated in your browser · nothing is uploaded
Builds a box-shadow from offset, blur, spread and colour, with as many stacked layers as you want and an inset option. The preview is a real element with the shadow applied.
How to use the box shadow generator
The one change that makes a shadow convincing is using more than a single layer. A real shadow is dense and tight where the object nearly touches its surface, and soft and wide further out, and no single shadow is both at once. Stacking two or three, a small dark one at low blur under a larger faint one at high blur, is what every design system does. It is also the reason a hand-written single shadow reads as a grey smear rather than as depth. Layers paint in order with the first on top, so the tight dark one belongs at the start of the list.
Spread is the value people skip and it does the most interesting work. It grows or shrinks the shadow before the blur is applied, which makes two useful things possible. A negative spread with a large blur pulls the shadow in tighter than the box and then softens it, giving the halo of genuine contact directly beneath a card. And a shadow with zero blur and a positive spread is not really a shadow at all: it is a ring that follows the border radius, sits outside the element, and takes up no space in the layout, which is why focus rings are so often built this way. The blur value is not a Gaussian standard deviation either; the specification asks for a blur approximating a Gaussian with a deviation of half the stated radius, so a 12px blur fades out over roughly 12px beyond the spread edge rather than 24.
Colour choice matters more than the numbers. Pure black at low alpha looks grey and lifeless, because a real shadow is the absence of a coloured light rather than a wash of neutral ink. Taking the hue of the surface underneath and darkening it, so a slightly blue-black on a cool page, reads as light instead of as dirt. None of that is a CSS feature; it is only what looks right.
What people use it for
- Getting a card off the page without the shadow reading as a grey smudge
- Building a focus ring from zero blur and a positive spread
- Putting a soft contact shadow under an element with a negative spread
- Matching an elevation step from a design system by eye
- Adding an inner shadow to a pressed or inset control
Questions
Almost always because it is one layer. A real shadow is tight and dark close in and soft and wide further out, and that needs at least two declarations stacked.
It grows or shrinks the shadow before the blur is applied. A negative spread with a big blur gives the soft contact shadow directly under a card; a positive spread with no blur gives a ring.
The first one in the list. Shadows paint front to back in the order written, the same way text-shadow does, so the tight dark layer goes first.
About the blur radius beyond the spread edge. The value is not a Gaussian sigma: the spec asks for a blur approximating a Gaussian of half that deviation.
No. It paints outside the element without taking any space, which is exactly why it works for focus rings. It is still clipped by an ancestor with overflow: hidden.
A drop-shadow filter follows the actual alpha shape, so it traces the transparent edges of a PNG or an SVG icon, and it has no spread value. A box-shadow always follows the border box, rounded corners included.