Layered soft shadow

Four layers whose blur doubles each step, so the edge is crisp and the fall-off is soft.

Open in the generator

Loads every layer, the box and the canvas exactly as shown, ready to adjust.

When to use it

This is the shadow for anything that is meant to float a little above the page and look like it belongs there: a card, a popover, a pricing panel, the console on this site's home page. It is the default I reach for when a client's theme has a single black shadow under every card and the whole page reads as flat cut-outs. Replace that one line with these four and the same page looks lit.

How it is built

Four layers, each twice the offset and twice the blur of the one before, each at low opacity, all in a dark tone of the page's own hue. Tobias Ahlin, whose article popularised the technique, describes the method as "creating multiple box-shadows (separating each shadow with a comma), and increasing the offset and blur for every shadow", and the doubling is simply the cleanest way to increase them. The first layer is the contact edge and sits on top; the last is the ambient glow and is painted first.

CSS
box-shadow:
  0 1px 2px rgba(27, 35, 64, 0.06),    /* contact edge, on top */
  0 4px 8px rgba(27, 35, 64, 0.06),    /* near                 */
  0 12px 24px rgba(27, 35, 64, 0.08),  /* mid                  */
  0 32px 64px rgba(27, 35, 64, 0.12);  /* ambient, underneath  */

layer 1
1 + 2
1 + 2 + 3
all four
The stack built up one layer at a time. Each layer adds distance without adding weight.

Tuning it for your page

Keep the offsets and blurs; change the colour and, if needed, the opacities. Josh Comeau's advice on colour is the rule: "By matching the hue and lowering the saturation/lightness, we can create an authentic shadow that doesn't have that 'washed out' grey quality." Take your page background, keep its hue, push the lightness right down, and use that as the shadow colour for every layer. On a pure white page a navy works; on a cream page a warm brown. If the element sits on a darker surface, raise the ambient layer's opacity to 0.18 rather than raising all four, because the wide layer is the one that separates the element from a mid-tone.

For a smaller element, a button say, drop the last layer; two or three are enough at that size and the 64 pixel blur would be wider than the button. For a modal that should float well clear of the page, keep all four and raise the third and fourth opacities a step.

Notes and limits

Four soft layers cost more to paint than one, so use this on the elements that carry the page, not on every row of a long list; two layers are enough for list items. Never transition the value on hover. And check it on the dark canvas in the generator before shipping: on a near-black surface no amount of tinted shadow shows, and the right move there is a luminous inset edge, which the inset shadows guide covers.

The code in four formats

Straight from the generator's readout for this state. Copy the one your project speaks; the output formats guide explains where each goes.

CSS
box-shadow:
  0 1px 2px rgba(27, 35, 64, 0.06),
  0 4px 8px rgba(27, 35, 64, 0.06),
  0 12px 24px rgba(27, 35, 64, 0.08),
  0 32px 64px rgba(27, 35, 64, 0.12);
border-radius: 16px;

SCSS
$shadow:
  0 1px 2px rgba(27, 35, 64, 0.06),
  0 4px 8px rgba(27, 35, 64, 0.06),
  0 12px 24px rgba(27, 35, 64, 0.08),
  0 32px 64px rgba(27, 35, 64, 0.12);

.element {
  box-shadow: $shadow;
  border-radius: 16px;
}

Tailwind
<div class="shadow-[0_1px_2px_rgba(27,35,64,0.06),_0_4px_8px_rgba(27,35,64,0.06),_0_12px_24px_rgba(27,35,64,0.08),_0_32px_64px_rgba(27,35,64,0.12)] rounded-[16px]"></div>

/* Or name it once in your theme (Tailwind v4): */
@theme {
  --shadow-custom: 0 1px 2px rgba(27, 35, 64, 0.06), 0 4px 8px rgba(27, 35, 64, 0.06), 0 12px 24px rgba(27, 35, 64, 0.08), 0 32px 64px rgba(27, 35, 64, 0.12);
}
/* then use class="shadow-custom" */

Stylus
.element
  box-shadow 0 1px 2px rgba(27, 35, 64, 0.06), 0 4px 8px rgba(27, 35, 64, 0.06), 0 12px 24px rgba(27, 35, 64, 0.08), 0 32px 64px rgba(27, 35, 64, 0.12)
  border-radius 16px

Frequently asked questions

What is a layered box shadow?

Several shadows in one comma separated box-shadow value, each with a different offset and blur, stacked so the element gets a crisp contact edge and a soft, wide fall-off at the same time. One shadow can only give you one of those.

What are good values for a soft box shadow?

Four layers with offset and blur doubling each step: 0 1px 2px, 0 4px 8px, 0 12px 24px and 0 32px 64px, at opacities of 6, 6, 8 and 12 per cent, in a dark tone of the page colour. That is the exact stack on this page.

Why is the shadow blue rather than black?

Because the page it falls on is a cool near-white. A shadow tinted to the surface hue reads as a shadow; a black one at the same opacity reads as grey dirt. Change the colour to a dark tone of your own page and keep the opacities.

Is a four-layer shadow slow?

Not to paint once. It costs more than one layer, but it is still well under a millisecond for a card. Avoid animating it; the card hover example shows how to lift it without repainting.

Sources

  1. Tobias Ahlin, Smoother and sharper shadows with layered box-shadows
  2. Josh W. Comeau, Designing Beautiful Shadows in CSS
  3. MDN Web Docs: box-shadow