Give a card some depth.

A good shadow makes a card, button or photo look as if it rests just above the page. Guessing the numbers is slow, so here you move sliders and watch a sample box change.

Start from a preset, fine-tune each layer, set the corner radius and the colours around it, then copy the CSS.

Runs in your browser. Nothing is uploaded.

More design & colour tools · All 54 tools

How to use it

  1. Pick a Preset such as Soft, Layered or Inset, or start from the default.
  2. For each layer, move the X offset, Y offset, Blur, Spread and Opacity % sliders and choose its Colour.
  3. Tick Inset to draw that layer inside the box instead of beneath it.
  4. Use Add layer (up to five) or Remove layer to change the stack.
  5. Set the Corner radius, Background and Box colour to match your page, then press Copy CSS.

Good to know

Reading a shadow value

box-shadow: [inset] x y blur spread colour;
  • x and y move the shadow right and down; negative values move it left and up.
  • blur softens the edge. Browsers draw it as a Gaussian blur whose standard deviation is half the blur value, so a bigger number gives a wider, softer edge.
  • spread grows the shadow before it is blurred (positive) or shrinks it (negative). A negative spread with a large Y offset gives a shadow that only peeks out at the bottom.
  • colour is written as rgb(0 0 0 / 10%), where the last number is the Opacity % slider. At 100% the plain hex colour is used.
  • inset draws the shadow inside the edge, which reads as pressed or sunken.

Why stack layers

A real object casts a tight, darker shadow close to it and a wide, faint one further out. Two or three layers imitate that. The Layered preset is a good model:

box-shadow: 0px 1px 2px 0px rgb(0 0 0 / 6%),
            0px 4px 8px 0px rgb(0 0 0 / 6%),
            0px 12px 24px -4px rgb(0 0 0 / 10%);

Layers are painted in reverse order, so the first one in the list sits on top.

Practical notes

  • A shadow follows the border-radius of its box, which is why the output includes it. Copy both lines.
  • Shadows take up no space in the layout. A parent with overflow: hidden can cut a large one off, so leave room around the element.
  • On a dark background a black shadow barely shows. A lighter card colour, a thin border or a soft coloured glow (see the Glow preset) shows depth better.
  • Animating large blurred shadows on many elements at once can make scrolling less smooth on older phones.

Questions.

What do the presets do?

Each loads a starting set of layers. Soft is one gentle shadow, Layered stacks three, Lifted makes a card look raised, Hard offset gives a flat shadow with no blur, Inset sinks the box and Glow adds a coloured halo. All of them can be edited.

Why is there a limit of five layers?

It keeps the controls manageable, and more than three or four layers rarely looks any different. CSS accepts more if you add them by hand.

Does box-shadow work on images and buttons?

Yes, on any element that has a box, including images and buttons. On a PNG with a transparent background the shadow follows the rectangle, while the CSS filter drop-shadow() follows the visible shape.

Can shadows slow a page down?

A few still shadows cost very little. Problems usually come from animating big blurs on many elements at the same time, especially on low-end phones.

Does the shadow adapt to dark mode?

Not by itself. If your site has a dark theme, give it its own shadow values, often with a lighter colour or a border, and preview them with Background set to your dark colour.