CSS box shadow generator

Design soft, layered or inner shadows visually and copy the box-shadow CSS. Control offset, blur, spread, color and opacity for up to three layers. Free, and it runs in your browser.

How to use it

  1. Set the offsets, blur and spread of layer 1, then pick its color and opacity.
  2. Tick Use layer 2 or Use layer 3 to stack more shadows, or inset for an inner shadow.
  3. Check the preview and click Copy on the CSS code.

Complete guide to CSS box-shadow

What box-shadow is for

A shadow tells the eye what is above what. Cards lift off the page, dropdowns float over content, pressed buttons sink in, focused fields glow. The box-shadow property draws all of this without images, and it follows the rounded corners of the element. The syntax packs five or six values in one line, and getting a shadow that looks natural rather than heavy takes some tuning. This tool lets you adjust each value, stack up to three layers, watch the result on a sample box and copy the finished declaration.

The values in order

PositionValueWhat it does
1Horizontal offsetMoves the shadow right (positive) or left (negative)
2Vertical offsetMoves the shadow down (positive) or up (negative)
3BlurHow soft the edge is. 0 is a hard edge, never negative
4SpreadGrows (positive) or shrinks (negative) the shadow before blurring
5ColorWritten by the tool as rgba(), combining the color and the opacity
OptionalinsetDraws the shadow inside the box instead of outside

You pick the color with the color picker and the opacity with a separate 0 to 100 slider. The tool turns them into one rgba() value, for example black at 25% becomes rgba(0, 0, 0, 0.25). Zero values are written without a unit. Several layers are joined with commas, and the first one is drawn on top.

Worked example

  1. With every field on its default, layer 1 is 0, 10, 25, -5 in black at 25% and the result is box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.25);. The negative spread pulls the shadow in so it shows mostly below the box.
  2. For a crisp inner effect, set Layer 1: horizontal offset (px) and Layer 1: vertical offset (px) to 4, Layer 1: blur (px) and Layer 1: spread (px) to 0, Layer 1: color to red, Layer 1: opacity (%) to 100 and tick Layer 1: inset (inner shadow). The result is box-shadow: inset 4px 4px 0 0 rgba(255, 0, 0, 1);.
  3. For a realistic card, tick Use layer 2 and set layer 1 to offset 0 and 2, blur 4, spread 0, opacity 20, then layer 2 to offsets 0 and 12, blur 32, spread 0, opacity 12. The result is box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2), 0 12px 32px 0 rgba(0, 0, 0, 0.12);: a tight contact shadow plus a wide soft one.

Why layers look better

Light in the real world produces a dark, sharp shadow close to the object and a wide, faint one further away. A single shadow cannot do both, so it tends to look either muddy or like a flat sticker. Two layers, one small and darker and one large and lighter, copy that behavior. Use Use layer 2 and Use layer 3 for it, and keep the opacities low: 5% to 25% is usually enough on a light background.

Tips and common mistakes

  • Shadows are not part of the box size and do not push other elements. They can be cut off by a parent with overflow: hidden, so leave room around the element.
  • On dark backgrounds a black shadow disappears. Raise the opacity, or use a colored or lighter shadow instead.
  • Use Box corner radius (px) to match the radius of your real element, because the shadow follows the corners.
  • Very large blurs on many elements can slow scrolling on weak devices. Keep them for a few key surfaces.
  • The color fields only accept the values from the color pickers, so the generated rgba() is always valid.

Related tools

Round the box first with the border radius generator. To pick a shadow tint, convert it with the color converter, and check any text on top with the contrast checker.

Questions

What do the values mean?

The first two are the horizontal and vertical offset, the third is blur (how soft the edge is), and the fourth is spread (how much the shadow grows or shrinks). Then comes the color.

Why use more than one layer?

Stacking a tight, darker shadow with a wide, lighter one looks more natural and realistic than a single heavy shadow.

What does inset do?

It draws the shadow inside the element instead of outside, which is useful for pressed buttons and input fields.

Why is opacity separate from color?

The tool converts the HEX color and opacity into a single rgba() value, which keeps the CSS simple and works everywhere.