Box Shadow Generator
Developer Tools ยท Added
Set the offset, blur, spread and colour and watch the shadow change on a real element. The part that matters is stacking: a single shadow layer reads as a grey smudge, while two โ one tight and dark for the contact edge, one wide and faint for the ambient cast โ reads as depth. This builds either, plus inset shadows and the spread-only trick behind focus rings.
CSS
box-shadow: 0px 4px 12px -2px rgba(15, 23, 42, 0.15);Subtle border: A one-pixel shadow used instead of a border, so it does not affect layout.
Card: Two layers: a close contact shadow and a softer ambient one.
Raised: For a menu or popover โ far enough off the surface to read as floating.
Inset well: An inner shadow, which is what makes an input look recessed.
Focus ring: A spread-only shadow with no blur โ a visible focus indicator that costs no layout.
A box-shadow paints outside the element and never affects layout, which is why it is the right way to draw a focus ring or a hairline border that must not shift anything. It is also drawn on every paint, so a very large blur across many elements is one of the few CSS properties that can genuinely cost frames on a slow device.
How to use the box shadow generator
- 1Adjust the horizontal and vertical offsets to set where the light is coming from. Real light is usually above, so a small positive vertical offset is the common case.
- 2Set the blur, and the spread if you want the shadow larger or smaller than the element.
- 3Choose a translucent colour rather than a light grey โ it tints what is behind it instead of sitting on top as a flat patch.
- 4Add a second layer for depth: keep the first tight and dark, and make the second wide and faint.
- 5Tick Inset for an inner shadow, then copy the declaration.
Examples
A card
- Input
- Two layers, both dark and translucent
- Result
- box-shadow: 0px 1px 3px 0px rgba(15, 23, 42, 0.1), 0px 8px 24px -4px rgba(15, 23, 42, 0.12);
The first layer is the contact edge, the second the ambient cast. One layer alone cannot do both.
A focus ring
- Input
- No offset, no blur, 3px spread
- Result
- box-shadow: 0px 0px 0px 3px rgba(37, 99, 235, 0.45);
A spread-only shadow is a ring that costs no layout, which a border would.
A recessed input
- Input
- Inset, 2px down, 4px blur
- Result
- box-shadow: inset 0px 2px 4px 0px rgba(15, 23, 42, 0.12);
About the box shadow generator
Reading the syntax
The values run in a fixed order: horizontal offset, vertical offset, blur, spread, colour. Only the offsets are required, which is why so many shadows in the wild are two numbers and a colour. The optional inset keyword goes at the front and moves the shadow inside the element.
Multiple shadows are comma separated, and the first one paints on top. That ordering matters when layers overlap at different opacities โ putting the tight dark layer last buries it under the faint one and loses the effect.
Shadows as an interface signal
In most interfaces the shadow is not decoration, it is a statement about layering: this element is above the page, and probably temporary. A dropdown, a modal and a tooltip all carry heavier shadows than a card for that reason, and a permanent piece of page furniture generally should not float at all.
The corollary is consistency. Two elements at the same conceptual level should carry the same shadow, and a set of arbitrary hand-tuned shadows across a site reads as sloppiness even when no individual one looks wrong. Picking three โ resting, raised, floating โ and reusing them is what design systems do.
Shadows in dark mode
A black shadow on a dark background does almost nothing, because there is no lightness left to remove. This is the most common reason a design that looks crisp in light mode looks flat when inverted.
The usual answers are to raise the surface colour instead of deepening the shadow โ lighter surfaces read as closer, which is what material design does โ or to keep a shadow for the contact edge and add a subtle light border to define the top. Copying the light-mode shadow values across is the one approach that reliably does not work.
Frequently asked questions
What is the difference between blur and spread?
Why do professional shadows use several layers?
Should a shadow be grey or translucent?
What is the difference from filter: drop-shadow?
Can shadows slow a page down?
Related tools
CSS Gradient Generator
Developer Tools
Build a linear, radial or conic CSS gradient visually and copy the declaration.
CSS Unit Converter
Converters
Convert px, rem, em, pt, %, vw and vh against a root font size you set.
Color Converter
Converters
Convert one colour between hex, RGB, HSL, HSV and CMYK, with hue-rotated sets alongside.