Smooth box shadow generator
Build smooth, layered CSS box shadows that behave like real light, not the flat grey smudge of a single shadow. Tune elevation, softness, light angle and colour on a live card, compare it with a single shadow, and copy CSS or Tailwind.
- Free, no signup
- Runs in your browser
- Nothing is uploaded
Shadow
Drag a label sideways to scrub a value, or type it.
Presets
Layers
Darkness right under the element, where all layers overlap.
Layer offsets
| 1 | 0.8px |
|---|---|
| 2 | 3.2px |
| 3 | 7.2px |
| 4 | 12.8px |
| 5 | 20px |
Light & colour
0° is light from straight above, so the shadow falls down. Keep one light angle across a whole product.
Preview
Code
box-shadow:
0 0.8px 1.6px -0.2px rgba(15, 23, 42, 0.039),
0 3.2px 6.4px -0.6px rgba(15, 23, 42, 0.039),
0 7.2px 14.4px -1.4px rgba(15, 23, 42, 0.039),
0 12.8px 25.6px -2.6px rgba(15, 23, 42, 0.039),
0 20px 40px -4px rgba(15, 23, 42, 0.039);How it works
How to use the box shadow generator
- 01
Start from a preset
Subtle, Card, Floating, Modal, Sharp or Inset. Each is a sensible elevation level you can ship as it is.
- 02
Tune the shadow
Set the number of layers, distance, blur, spread and opacity. Easing decides how the layers are spaced, from a tight core to a soft spread.
- 03
Set the light
Turn the light angle, tint the shadow with the background's hue, and try it on different backgrounds and corner radii.
- 04
Compare and copy
Put it next to a single shadow to see the difference, then copy plain CSS, a Tailwind class or a Tailwind v4 theme variable.
How real shadows behave
Real light sources have size, so real shadows have two parts: a dark core where the object blocks the light completely, and a soft edge where it only blocks part of it. The closer an object sits to a surface, the smaller, darker and sharper its shadow. Lift it and the shadow grows, lightens and softens.
A single CSS box-shadowcan't do both, because it is one blurred copy of the box. Make it tight and the element looks stuck to the page; make it big and soft and it looks like a vague grey cloud. The fix, popularised by Tobias Ahlin and Josh Comeau, is to stack several shadows that grow in offset and blur. The small ones build the contact shadow, the large ones the soft falloff, and together they read as one natural shadow.
How this generator builds the layers
For N layers, layer i gets a position t = i / N, passed through the easing curve. Its offset, blur and spread are your distance, blur and spread multiplied by that eased value. With ease-in (t²) and five layers, the offsets are 4%, 16%, 36%, 64% and 100% of the distance, close to the doubling sequence (1, 2, 4, 8, 16px) people often write by hand. Every layer shares one opacity, a = 1 − (1 − opacity)1/N, so where all the layers overlap the darkness equals the opacity you set. At 18% over five layers, each layer is about 3.9%. The Card preset produces:
box-shadow:
0 0.8px 1.6px -0.2px rgba(15, 23, 42, 0.039),
0 3.2px 6.4px -0.6px rgba(15, 23, 42, 0.039),
0 7.2px 14.4px -1.4px rgba(15, 23, 42, 0.039),
0 12.8px 25.6px -2.6px rgba(15, 23, 42, 0.039),
0 20px 40px -4px rgba(15, 23, 42, 0.039);Ease-in gives a tight core and a long tail, which suits most UI. Ease-out bunches the layers at the large end for a hazy, diffuse look; linear and ease-in-out sit in between.
Elevation systems: one light, a few levels
A product needs a handful of elevation levels used consistently, not a new shadow per component. Higher elements get bigger, softer, slightly darker shadows; the light angle and colour never change. The presets here make a workable four-step system:
| Level | Use it for | Distance | Blur | Opacity |
|---|---|---|---|---|
| Subtle | Resting cards, inputs, list items | 4px | 8px | 10% |
| Card | Raised cards, hovered items | 20px | 40px | 18% |
| Floating | Menus, popovers, sticky headers | 40px | 80px | 24% |
| Modal | Dialogs, command palettes, drawers | 64px | 128px | 32% |
Store them as tokens (--shadow-subtle, --shadow-card and so on) next to your colour and spacing values. That is what turns a pile of styles into a design system; see design tokens for how to organise them.
Common shadow mistakes
- Grey shadows on coloured backgrounds. Tint them with the background hue instead.
- Too dark, too tight. Above roughly 30% opacity on small elements, shadows start to look heavy and dated.
- Mixed light angles. If the cards cast shadows downwards and the dropdown casts them to the side, the interface feels subtly wrong. Pick one angle for everything.
- Positive spread for big glows. It pushes the shadow out on every side. A negative spread with a large blur keeps the shadow under the element, where light would put it.
- Animating box-shadow directly. Transitioning between two multi-layer shadows on many elements can drop frames. Fade a pseudo-element instead:
.card { position: relative; box-shadow: var(--shadow-card); }
.card::after {
content: "";
position: absolute;
inset: 0;
border-radius: inherit;
box-shadow: var(--shadow-floating);
opacity: 0;
transition: opacity 200ms ease-out;
}
.card:hover::after { opacity: 1; }Shadows are half of what makes an interface feel tactile; the other half is colour and type. Try the CSS gradient generator for backgrounds and the fluid type scale generator for headings, or have me design the whole thing as part of my product design work.
Common questions
Box shadow generator: FAQ
Several box-shadows stacked on one element, each with a larger offset and blur and a low opacity. Together they imitate a real shadow: dark and tight where the object meets the surface, soft and wide further out. A single box-shadow has one uniform blur, which is why it often looks like a flat grey smudge.
Need it done for you?