CSS Box Shadow Generator
Stack shadow layers with sliders, preview them on light and dark surfaces, and copy the box-shadow as CSS, Tailwind or a drop-shadow() filter.
Last checked
Layers
The first layer is drawn on top.
The code
box-shadow: 0 8px 24px -4px rgb(15 23 42 / 0.18);
- drop-shadow() has no spread, so spread is ignored.
Presets
Smooth layered shadow
Several layers whose offset and blur double each step. It looks closer to a real shadow than one big blur.
Edit an existing shadow
Elevation set
Three shadow tokens that share one light source and a colour taken from the preview background, so small, medium and large elements look lit by the same lamp.
0° is light from straight above; negative values move it to the left. Shadow colour #262d36.
:root {
--shadow-sm: 0 1px 2px rgb(38 45 54 / 0.09), 0 2px 4px rgb(38 45 54 / 0.09);
--shadow-md: 0 1.5px 3px rgb(38 45 54 / 0.07), 0 3px 6px rgb(38 45 54 / 0.07), 0 6px 12px rgb(38 45 54 / 0.07);
--shadow-lg: 0 1px 2px rgb(38 45 54 / 0.048), 0 2px 4px rgb(38 45 54 / 0.048), 0 4px 8px rgb(38 45 54 / 0.048), 0 8px 16px rgb(38 45 54 / 0.048), 0 16px 32px rgb(38 45 54 / 0.048);
}How to use it
- Pick a preset or start from the default layer, then move the sliders for offset, blur, spread and opacity, and choose a colour.
- Add more layers to build depth. Select a layer in the list to edit it; the preview updates as you go.
- Copy the CSS, the Tailwind class or the drop-shadow() version. To change a shadow you already have, paste it into the edit box and load it.
- For a design system, set the light direction and strength in Elevation set and copy the three tokens.
What it checks and why
A box-shadow layer has an x and y offset, a blur radius, an optional spread and a colour, and the inset keyword moves it inside the box. A comma-separated list stacks layers, with the first one drawn on top. Blur cannot be negative; spread can, which pulls the shadow in so it shows only below the box.
One large blurred shadow tends to look flat. Stacking several layers whose offset and blur double each step, each with a small share of the opacity, gives a soft falloff closer to a real shadow. The smooth layered builder writes that stack for you from a layer count, a distance and a total opacity.
The tool writes colours as rgb() with a slash alpha, the modern syntax every current browser supports. The drop-shadow() output follows the alpha of transparent images and SVGs instead of the box, but the filter has no spread and no inset, so the tool tells you which parts it had to leave out.
Shadows in one interface should look lit by the same lamp. The elevation set gives three tokens that share a light direction, grow longer and softer as the element rises, and take a dark tint of the background hue instead of plain grey, which reads as a real shadow on coloured surfaces.
Specs and sources
Limits
- Lengths are written in px. The edit box reads rem and em as 16px, and any colour the browser understands, but not CSS variables.
- Many large blurred layers cost paint time, more so when they animate. Animate the opacity of a pseudo-element that holds the shadow instead of the shadow itself.
- drop-shadow() draws differently from box-shadow on boxes with rounded corners and transparent parts, so check the filter version in your own layout.
Questions
- What do the four box-shadow values mean?
- In order: horizontal offset, vertical offset, blur radius and spread radius, followed by the colour. Only the two offsets are required; blur and spread default to 0.
- How do I add more than one shadow?
- Separate the layers with commas in one box-shadow declaration. The first layer is painted on top. The generator writes each layer on its own line so the list stays readable.
- How do I make a shadow only on the bottom?
- Give it a positive y offset and a negative spread about as large as the blur, for example 0 12px 12px -12px. The spread pulls the shadow in at the sides so only the bottom edge shows.
- What is the difference between box-shadow and drop-shadow?
- box-shadow follows the element's box and border radius. filter: drop-shadow() follows the visible pixels, so it hugs transparent PNGs and SVG shapes, but it has no spread and no inset.
- How do I write a custom shadow in Tailwind?
- Use an arbitrary value: shadow-[0_8px_24px_-4px_rgb(15_23_42_/_0.18)]. Spaces become underscores. The generator writes that class for you from the current layers. For a set of shadows, copy the Elevation set as a Tailwind v4 @theme block, which redefines shadow-sm, shadow-md and shadow-lg.
- How do I make a soft, realistic shadow?
- Stack several layers instead of one big blur: each layer doubles the offset and blur of the one before and gets a small share of the opacity. Use the smooth layered builder, and tint the shadow towards the background colour rather than pure black.
- How do I make a neumorphism shadow?
- Give the box the same colour as the page and add two shadows: a dark one offset down and right, and a light one offset up and left. The Neumorphic preset does that; pick the Custom surface to set the page and box colours.
- Is it bad for performance to animate box-shadow?
- Animating box-shadow repaints the element on every frame. Put the shadow on a pseudo-element and animate its opacity instead, which the browser can run on the compositor.