CSS Box Shadow Generator
Designing with one light source
The single most effective rule in shadow design is consistency: pick one imaginary light — usually above and slightly to one side — and let every shadow in the interface obey it. Offsets that point down-right on cards but down-left on modals look wrong in a way users feel without naming. Elevation is the second system: in design systems like Material, shadow size encodes height above the surface, so a resting card, a raised card, a dropdown and a modal form a ladder of blur and offset values rather than four improvisations. Build your ladder once — this generator is a good place to tune it — and reuse the rungs.
Coloured shadows deserve a mention: a shadow tinted with the element's own colour (a blue button casting a faint blue shadow) is a current, softer alternative to neutral grey, and works because the rgba colour field accepts anything. Keep the opacity low; tint is a seasoning, not a sauce.
Presets worth stealing
Four recipes cover most interfaces. Resting card: 0 1px 2px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.06) — barely there, just enough to separate from the page. Raised card / dropdown: 0 4px 8px rgba(0,0,0,0.10), 0 12px 28px rgba(0,0,0,0.14). Modal: 0 24px 64px rgba(0,0,0,0.28) with a tight 0 2px 6px contact layer — the big soft field sells the height. Inner well (inset): inset 0 2px 6px rgba(0,0,0,0.15) for inputs and recessed panels. Build each layer in the generator in turn and join with commas. Notice the pattern across all four: as the shadow grows, its opacity falls — big and dark is the one combination that always looks like a mistake, because no real light source produces it.
Shadows also carry meaning users read unconsciously: the higher an element floats, the more likely it is to be interactive, temporary or important — a modal outranks a dropdown, which outranks a card. Spending your biggest shadows on static decoration inverts that language and teaches users to ignore the signal. Audit an interface by squinting at it: the elements that visually lift off the page should be exactly the elements that would disappear if you clicked elsewhere. When the squint test and the interaction model agree, the shadow system is doing its job.
Frequently asked questions
What is the syntax of box-shadow in CSS?
box-shadow: offset-x offset-y blur-radius spread-radius colour, with the keyword inset optionally placed first or last. For example, 8px 8px 16px 0px rgba(0,0,0,0.25) drops a shadow 8 pixels right and 8 down, softened by a 16-pixel blur, at its natural size, in black at 25% opacity. The two lengths that may be omitted default sensibly: leave out the spread and it is 0, leave out the colour and it takes the element's text colour. Multiple shadows are comma-separated and painted front to back — the first shadow in the list sits on top — which is how layered, realistic shadows are built.
What do blur and spread do differently?
Blur softens the shadow's edge without changing its size: a 0 blur gives a hard-edged silhouette, and larger values feather it outward in both directions. Spread resizes the shadow before blurring: positive spread makes it bigger than the element on all sides, negative spread shrinks it — the trick behind shadows that hug only one edge. To fake a shadow on the bottom only, designers combine a positive vertical offset with a negative spread of the same size, so the shadow contracts away from the other three sides and peeks out only underneath. The preview box in this generator makes the distinction obvious in a way numbers never quite do.
What does inset do?
It moves the shadow inside the element's border box, clipped to the inside: instead of a drop shadow cast outward, you get an inner shading, as if the element were a recess or the light were pressing its edges in. Inset shadows are the standard tool for pressed buttons, wells, input fields that look carved into the page, and subtle inner glows (a large-blur, low-opacity white inset on a dark card). Inset and outset shadows can coexist on the same element as separate layers in the comma list, and each layer chooses independently.
How do I make a realistic, soft shadow?
Layer two shadows, like real light does: a small, darker, sharp one for the contact shadow where the object meets the surface, and a larger, lighter, heavily blurred one for the ambient falloff. Something like 0 1px 2px rgba(0,0,0,0.20), 0 8px 24px rgba(0,0,0,0.12) reads as physical where a single 0 8px 16px grey blur reads as decoration. Keep the colour a darkened version of the surface or plain black at low opacity, keep offsets consistent across a whole interface (one imaginary light source), and reserve the biggest shadows for the elements meant to feel highest. Build the pair here by generating each layer in turn and joining the two values with a comma in your stylesheet.
Does box-shadow affect layout or performance?
Layout, no: shadows are pure paint, overflowing visually without taking space, triggering scrollbars or shifting neighbours (outline behaves similarly; border and margin do not). Performance, sometimes: a very large blur radius over a very large area is expensive for the browser to repaint, and animating box-shadow forces a repaint every frame — the standard optimisation is to animate the opacity of a pre-rendered shadow layer, or transform, instead. For static interface shadows at ordinary sizes, the cost is negligible and not a reason to avoid them.
Related tools
Figures checked on 24 November 2026. Everything is calculated in your browser — nothing you type is sent anywhere.