Skip to content
DoItJag

CSS Box Shadow Generator

Get the shadow you have in mind without trial and error in a code editor. Move the sliders for offset, blur and spread, set the colour and opacity, switch to an inner shadow or stack several shadows for a softer, more natural look. The preview box and the CSS update as you go.

Presets

Shadow 1
Download .css

About the CSS Box Shadow Generator

Shadows give flat page elements a sense of depth: a card lifts off the background, a button looks pressable, a dialog floats above the page. The CSS box-shadow property does this with five numbers and a colour, but small changes make a big visual difference, so tuning it by eye is far quicker than guessing values in a stylesheet.

What each control does

  • Horizontal and vertical offset move the shadow. Positive values push it right and down, as if light came from the top left.
  • Blur softens the edge. Zero gives a crisp, hard-edged copy of the box.
  • Spread grows or shrinks the shadow before blurring. A negative spread keeps a soft shadow tucked under the box.
  • Opacity controls how dark the shadow is. Most natural-looking shadows sit between 10% and 30%.
  • Inner shadow draws the shadow inside the box instead, which suits input fields and pressed buttons.

Worked example

Choose the Card (two layers) preset. The first layer is small and close (1px down, 3px blur at 12% black), the second is wide and faint (8px down, 24px blur, minus 4px spread at 18%). Together they look like a card resting a little above the page. Remove the second layer and the card suddenly looks flat and outlined rather than lifted.

Matching your design

Set the box and background colours to the ones on your site, because the same shadow looks much stronger on a white page than on a grey one. On a coloured background, try a shadow in a darker shade of that colour rather than black; it looks richer and less muddy. The corner radius is included in the code so the shadow follows rounded corners.

Performance and accessibility

A few static shadows cost almost nothing. Be careful when animating them on hover across many elements, which can make scrolling stutter on older phones. Shadows alone should not be the only sign that something is clickable, since people with low vision may not notice them.

How to use CSS Box Shadow Generator

  1. Start from a preset or move the offset, blur, spread and opacity sliders.
  2. Add more shadow layers or tick "Inner shadow" if you need them; set the box and background colours to match your design.
  3. Copy the CSS or download it as a .css file.

Privacy: how it works

Everything happens in your browser. Nothing you choose or type is sent to any server.

Frequently asked questions

What is the difference between blur and spread?

Blur softens the edge of the shadow. Spread makes the shadow larger (positive) or smaller (negative) than the box before it is blurred. A negative spread with a large blur gives a soft shadow that stays under the box.

Why use more than one shadow?

Real shadows have a dark, tight part near the object and a faint, wide part further away. Two layers, one small and one large, imitate this. The first layer in the list is drawn on top.

Does box-shadow slow a page down?

Static shadows are cheap. Very large blur values on many elements, or animating box-shadow itself, can make scrolling less smooth on slow phones.