Skip to content
Box Shadow Generator

Box shadow generator with real layers — why one shadow always looks flat

Stack as many box-shadow layers as you like, reorder them, and copy a rule written one layer per line. Every layer carries its own offset, blur, spread, colour, opacity and inset switch, and the preview draws them on an element whose colour and background you set yourself — a shadow judged against the wrong surface is a shadow judged wrongly. The page also prints how far the shadow reaches past the edge of the box on each side, which is the number that decides whether a parent is going to clip it.

  • Nothing is uploaded or saved
  • Works offline
Shadow layers

The first layer in this list is painted on top of the ones below it — the same order it appears in the CSS.

1. 0 1px 2px rgba(0, 0, 0, 0.3)
Offset X0px
Offset Y1px
Blur2px
Spread0px
Colour
30%
2. 0 8px 24px -4px rgba(0, 0, 0, 0.22)
Offset X0px
Offset Y8px
Blur24px
Spread-4px
Colour
22%
CSS
.card {
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.3),
    0 8px 24px -4px rgba(0, 0, 0, 0.22);
}

One layer per line. A four-layer shadow written on a single line is unreadable in a diff, and the comma is the only thing separating one shadow from the next.

Preview
2 layers
Element
Behind it
Corner radius0px
Layers
2
Reaches out
16px

Furthest the shadow travels past the edge: 0px up, 8px right, 16px down, 8px left. Half of a blur falls outside the shadow’s own edge, so a 24px blur reaches 12px further than the offset alone suggests — that is the number that decides whether a parent needs to stop clipping.

Presets

Our own numbers, not values lifted from a named design system. Load the first two one after the other — same darkness, different number of layers.

Related tools on this site: build a CSS gradient, convert the shadow colour to another notation and lay the cards out with CSS Grid.

How it works

  1. 1

    Start from two layers, not one

    Load the “Contact + ambient” preset and look at what it is made of: a tight, dark shadow a single pixel down with almost no blur, and a wide, faint one much further down. The first is where the object meets the surface. The second is the light from the rest of the room. Everything that reads as depth is some version of those two, and no single set of four sliders can produce them at once.

  2. 2

    Set the surface and what is behind it

    The preview lets you choose the colour of the element and the colour behind it, because a black shadow at 20% opacity is dramatic on white and nearly invisible on dark grey. Most shadow generators show you a dark shape on a white page and then you paste it into a dark interface and wonder where it went. Set both colours to the ones you are actually shipping before you judge any of the numbers.

  3. 3

    Use spread to control the shape, blur to control the softness

    Spread grows or shrinks the shadow before it is blurred. Negative spread is the quiet trick that makes big shadows work: a large blur alone bleeds out sideways and makes the element look like it is floating in fog, while the same blur with −8px of spread pulls the shape back in and leaves the softness where you want it, underneath. Every layer in the “Lifted” preset carries a negative spread for that reason.

  4. 4

    Reorder and duplicate rather than restart

    The first layer in the list is painted on top of the ones under it, so order changes the result whenever layers overlap — an opaque ring above a soft shadow looks different from the same two the other way round. Duplicate a layer, double its blur, halve its opacity, and you have the next step of a falloff in two clicks instead of typing four numbers again.

  5. 5

    Check the reach before you paste

    Under the preview the page reports how far the shadow travels beyond each edge. Half of a blur falls outside the shadow’s own boundary, so a 24px blur reaches 12px further out than the offset alone suggests, and spread adds to that. If any parent of your element has overflow hidden, that number is how much of the shadow it is about to cut off.

Frequently asked questions

Why do layered shadows look real and a single one does not?

Because a real shadow has more than one edge. Where an object touches a surface, light is blocked completely and the shadow is dark and sharp; a few centimetres away it is softened by light arriving from every other direction and becomes wide, pale and diffuse. A single box-shadow has one blur radius, so it has exactly one edge softness across its whole extent — which is a shape that nothing in the physical world casts. Two layers give you two softnesses, four give a falloff. Load the “One layer” preset, then the “Contact + ambient” preset, with the same colours behind them: the total darkness is similar and only one of them reads as an object sitting above a surface.

What is the difference between blur and spread?

Spread happens first and changes the size of the shadow shape: a positive value grows the rectangle in every direction before anything is blurred, a negative one shrinks it. Blur then softens the edge of whatever shape spread produced. The practical difference is that spread moves the edge and blur only fuzzes it, so `0 0 0 3px` is a solid three-pixel outline with no softness at all, while `0 0 3px 0` is a faint halo hugging the original edge. Set blur to zero in the tool above and drag spread to see the shape change with the softness held still.

How far outside the box does a shadow actually reach?

The blur is centred on the edge of the shadow shape, so half of it falls outside and half inside. That means the outer reach is the offset, plus the spread, plus half the blur. A layer written `0 8px 24px -4px` reaches 8 + (−4) + 12 = 16px below the box and 12 − 4 − 8 = 0px above it. The tool prints those four numbers for the whole stack while you edit, so you never have to work out which parent needs its overflow left alone.

What does inset actually do?

It draws the shadow on the inside of the padding box instead of behind the element, as if the light were coming from outside a hole rather than falling on a raised object. Everything else works the same way, but the directions invert in a way that surprises people the first time: a positive Y offset on an inset shadow darkens the top edge, because the shadow is being cast down onto the inner surface from the lip above it. That is what makes an inset shadow read as a pressed button or a sunken input. Inset and outer layers can be mixed freely in one declaration — the “Inset well” preset above does exactly that, using a one-pixel light line on the outside to suggest an edge catching the light.

Does box-shadow affect the layout of the page?

No, and this is one of the genuinely useful facts about it. A shadow takes up no space at all: it does not push neighbours around, does not change the element’s size, and does not enter into any layout calculation. That is why `box-shadow: 0 0 0 2px` is such a common focus ring — it looks exactly like a 2px border but, unlike a border, adding it does not make the element 4px wider and shift everything beside it. A shadow can, however, be clipped by an ancestor with overflow hidden, since clipping is a paint decision rather than a layout one.

I have several shadows. Which one is on top?

The first one in the list. Shadows are painted in the order they are written, with the first drawn last and therefore highest — the opposite of the intuition most people bring from stacking layers in a design tool. It only matters when layers overlap and at least one of them is close to opaque; four translucent black layers look much the same in any order, but a solid coloured ring will hide anything written after it. The tool numbers the layers in painting order and gives every one of them a move control so you can try both ways in a second.

Should I use filter: drop-shadow() instead?

Sometimes, and they are genuinely different tools. box-shadow follows the border box — a rectangle, or a rounded one — so it draws a rectangular shadow even behind a transparent PNG or an irregular SVG. filter: drop-shadow() follows the alpha channel of what is actually painted, so it traces the visible shape of a cut-out logo or an icon. The costs are that drop-shadow takes no spread value, that each call produces one shadow so a layered effect needs the filter repeated, and that a filter creates a containing block that can change how fixed and absolute positioning behave inside the element. Use box-shadow for boxes and drop-shadow for shapes.

How do I get a coloured shadow rather than a grey one?

Change the layer colour to a darker, more saturated version of the surface the shadow is falling on, rather than to a tint of the element itself. Pure black at low opacity desaturates whatever is under it, which is why shadows on a warm background so often look like a smudge of dirt. Set the preview’s backdrop to the real page colour, then pull the shadow colour towards a deeper version of it and raise the opacity to compensate; the result reads as shade rather than as grey paint. Keep the strongest colour on the widest, faintest layer — the tight contact layer is small enough that near-black is usually right for it.

Are large blurred shadows slow?

They are painting work, not layout work, so they never trigger a reflow — but a blur has to be computed over an area that grows with the radius, and a big blur on a big element repeated over many elements in a long scrolling list is real work for the compositor. There is no single threshold worth printing here, because it depends on the device, the size of the element and how often the area is repainted, and a number invented for this page would be worse than no number. The advice that holds: keep the number of layers to what the effect needs, avoid animating blur or spread frame by frame, and if a list feels heavy, measure it in your own browser’s performance panel rather than guessing.