All tools

Box shadow generator

Design layered CSS box shadows with a live preview.

Configuration

Shadow layers
Shadow color
Presets
Preview
Box color
Background

Result

CSS
box-shadow: 0px 4px 6px -1px rgba(0, 0, 0, 0.1),
    0px 10px 15px -3px rgba(0, 0, 0, 0.1);

About the Box shadow generator

The CSS box-shadow property adds depth to cards, buttons, dialogs and menus. Getting it to look natural by hand takes a lot of trial and error with offsets, blur and transparency.

This generator shows the shadow live as you adjust it. You can stack several layers, which is how most modern designs get soft, realistic shadows, and start from presets such as subtle, floating, hard, inset or glow.

How to use the Box shadow generator

  1. Pick a preset, or adjust the offset, blur, spread, color and opacity of the selected layer.
  2. Click Add layer to stack another shadow, and select a layer to edit it.
  3. Change the box color, background and corner radius to match your design.
  4. Click Copy CSS and paste the box-shadow line into your stylesheet.

Examples

Soft card shadow

Input

2 layers · 0 1px 2px 8% black · 0 8px 24px 12% black

Output

box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.08),
    0px 8px 24px 0px rgba(0, 0, 0, 0.12);

Two layers, one tight and one wide, look more natural than a single dark shadow.

Inner shadow for a pressed button

Input

Inset · 0 2px 4px 20% black

Output

box-shadow: inset 0px 2px 4px 0px rgba(0, 0, 0, 0.2);

Common errors and how to fix them

The shadow is cut off

A parent has overflow: hidden. Add padding to the parent, or move the shadow to an element that isn't clipped.

The shadow doesn't follow a transparent PNG's outline

box-shadow always follows the element's box. For the shape of an image, use filter: drop-shadow(0 4px 8px rgba(0,0,0,.2)).

Scrolling feels slow with big shadows

Large blur radii on many elements are expensive to paint. Use smaller blurs, or animate the opacity of a pseudo-element that has the shadow instead of animating the shadow itself.

Good to know

  • The values are, in order: horizontal offset, vertical offset, blur radius, spread radius and color. A positive vertical offset moves the shadow down, like light from above.
  • Several shadows are separated by commas and drawn with the first one on top. A tight, darker shadow plus a large, faint one usually looks more natural than a single shadow.
  • Inset draws the shadow inside the box, which is useful for pressed buttons and input fields.
  • Colors are written as rgba() with the opacity you set, which works in every browser.
  • Shadows don't take up space in the layout, so they never move other elements. They follow the element's border-radius.

Frequently asked questions

What's the difference between blur and spread?

Blur softens the shadow's edge: the larger it is, the more gradual the fade. Spread grows or shrinks the shadow before blurring; a negative spread makes it smaller than the box, which keeps large blurred shadows from looking muddy.

Can I add a shadow to an image with transparency?

box-shadow follows the element's rectangular box. For the shape of a transparent PNG or SVG, use filter: drop-shadow(...) with the same offset, blur and color values instead.

Do box shadows slow down a page?

A few shadows are cheap. Very large blurs on many elements, or animating box-shadow itself, can be slow on low-end devices. To animate a shadow, fade in a pseudo-element that has the shadow by changing its opacity.