CSS Box Shadow Generator

Adjust the offset, blur, spread, colour and opacity of one or more shadow layers and watch the box change. Start from a preset if you like, then copy the finished box-shadow rule into your CSS.

How to use the CSS Box Shadow Generator

  1. Pick a preset or start with the default soft shadow.
  2. Move the sliders for horizontal and vertical offset, blur, spread and opacity, and choose the colour.
  3. Add more layers for a smoother, more natural shadow, or tick Inset to put the shadow inside the box.
  4. Press Copy CSS and paste the rule into your stylesheet.

What each number does

A box-shadow takes up to four lengths and a colour: horizontal offset, vertical offset, blur radius and spread radius. A positive horizontal value moves the shadow right and a positive vertical value moves it down. Blur softens the edge and cannot be negative; spread grows or shrinks the shadow before the blur is applied.

Example: box-shadow: 6px 6px 0 rgba(15, 23, 42, 0.9) is a hard shadow, 6 pixels right and 6 pixels down with no blur, which gives a flat offset look. Setting blur to 0 and spread to 3px with no offset draws a solid ring around the box, like an outline.

Why layers look better

Real shadows are sharp close to an object and soft farther away. A single blurred shadow looks flat; several layers with increasing offset and blur, each at low opacity, look closer to that. The Layered preset uses three layers, each at 12 percent opacity.

Keep shadows subtle. A low opacity dark blue-grey usually looks cleaner than pure black, and very large blur values can be slow to paint on long pages and on weak devices.

Frequently asked questions

What does inset do?

It draws the shadow inside the box edge instead of outside, which makes the box look pressed in.

Can I add more than one shadow?

Yes. Layers are separated by commas in the CSS, and the first layer is painted on top.

Why is there no negative blur?

CSS does not allow a negative blur radius, so the tool keeps it at zero or more.

Does the CSS work in all browsers?

box-shadow is supported by all current browsers (see the MDN page under Sources).

Sources

Last reviewed