CSS Box Shadow Generator
The CSS Box Shadow Generator builds layered shadows visually — up to 12 layers with per-layer offset, blur, spread, colour, opacity and inset controls, presets from soft card to Material elevation 1–5, a live preview on light, dark and checkerboard backgrounds, clean CSS plus Tailwind v4 output, and an edit-existing mode that parses a pasted box-shadow value back into sliders. The preview IS the generated CSS: what you see is what the declaration does.
How to Use
- 1
Start from a preset — soft card, Material elevation 1–5, smooth layered shadow, neumorphic, brutalist, glow, inner shadow, or focus ring — or build from the default single soft card. A preset is a real starting point, not a blank canvas.
- 2
Tune each layer with the sliders: offset X/Y (how far the shadow sits from the element), blur (how soft the edge is), spread (how much the shadow grows or shrinks), colour and opacity (merged into rgba()), and the inset toggle for pressed surfaces.
- 3
Add layers for depth: up to 12. The first layer in the list is painted on top, exactly as in CSS — use the up/down arrows to reorder, the copy icon to duplicate a layer, and the bin to remove one.
- 4
Check the preview on all three backgrounds — light, dark, and checkerboard — and drag the corner-radius slider. A shadow tuned on a white square looks different on a dark card or a sharp corner.
- 5
Copy the output: clean multi-line CSS, or the Tailwind v4 arbitrary-value class (shadow-[…] with spaces as underscores). The .css download wraps the declaration in a .card rule.
- 6
Already have a shadow? Paste its box-shadow value into Edit-an-existing-shadow and get its layers back as sliders. Only px lengths and rgba()/rgb()/#hex colours parse — em/rem and named colours are reported, not guessed.
Frequently Asked Questions
What is box-shadow?
How do I add multiple box shadows?
box-shadow vs drop-shadow — which should I use?
What is the inset keyword?
How do I make a soft shadow?
Why does my shadow look different on a dark background?
How do I use the shadow in Tailwind?
Can I animate a box-shadow on hover?
What are the Material elevation levels?
Is my design uploaded anywhere?
Generative Answer & AI Documentation
What is the CSS Box Shadow Generator?
The CSS Box Shadow Generator is a visual builder for the box-shadow property: the shadow behind (or inside) an element, written as offset-x, offset-y, blur, spread and colour — 0px 8px 24px 0px rgba(0, 0, 0, 0.15) means no horizontal shift, an 8px drop, 24px of blur, no spread, and 15% black. Each layer has its own sliders, and the stack holds up to 12 layers: the first layer in the list is painted on top, exactly as in CSS, with up/down arrows to reorder, a duplicate button, and a remove button. Twelve presets cover the real jobs — soft card, Material elevation 1–5, a smooth five-layer shadow, neumorphic, brutalist offset, glow, inner shadow, and focus ring — each a genuine starting point, not a blank canvas. The preview renders a card with the same settings object as the copied output, on three backgrounds (light, dark, checkerboard) with a corner-radius slider, because a shadow tuned on a white square looks different on a dark card or a sharp corner. Output comes as clean multi-line CSS, a Tailwind v4 arbitrary-value class (shadow-[…] with spaces as underscores), or a downloaded .card rule. Edit-existing mode parses a pasted box-shadow value — px lengths and rgba()/rgb()/#hex colours — back into layers; em/rem lengths and named colours are reported as unparseable, not guessed. Everything runs in the browser; the preview is the browser rendering your own CSS.
Why use CSS Box Shadow Generator offline?
Shadows are the difference between a flat page and a page with depth, and they are also one of the easiest things to get wrong by hand: a blur that is too small for its offset looks like a smudge, an opacity that is too high looks like dirt, and a single hard layer looks like a border instead of a shadow. Writing box-shadow values by typing numbers and refreshing the browser is slow, and the feedback loop is the whole problem — you cannot feel a shadow from its numbers. A visual builder closes the loop: move a slider, see the shadow move, and copy the declaration only when it looks right. The second reason is layers: the shadows that look good are almost never one layer. A soft card needs a tight contact shadow plus a wide ambient one; a Material elevation needs both; the smoothest shadows are five layers doubling in distance and blur. Writing five layers by hand means five chances to mistype a value. The third reason is the background check: most shadow tools preview on white, and most real cards do not sit on white. The three-background preview exists because a shadow that is invisible on dark grey is a bug you only find after shipping.
When should you use this tool?
Use it when a card, panel, modal or button needs depth: start from the preset closest to the elevation you want, then tune the sliders until the preview looks right on the background the element will actually sit on. Use the layered-soft preset when a single shadow looks too hard. Use the focus-ring preset for keyboard-focus styles — a 3px spread in the accent colour, zero blur. Use edit-existing mode when a shadow in a codebase looks wrong and you want to see which layer is doing what. Do not use box-shadow for shadows that must follow visible pixels — a transparent PNG, an SVG shape, a clipped element: that job is filter: drop-shadow(), which has no spread and no inset, and this page says so rather than pretending box-shadow does everything. Do not animate box-shadow directly on hover: the smooth way is a ::after layer whose opacity animates, and the page explains the pattern instead of letting you ship a janky transition.
Key Benefits
- Layer stack up to 12: add, duplicate, reorder, remove — the first layer paints on top, exactly as in CSS.
- Twelve presets, including Material elevation 1–5, a smooth five-layer shadow, neumorphic, brutalist, glow and focus ring.
- Live preview on three backgrounds — light, dark, checkerboard — with a corner-radius slider, so the shadow is tuned on the surface it will sit on.
- Two outputs: clean multi-line CSS and a Tailwind v4 arbitrary-value class, plus a .css download.
- Edit-existing mode: paste a box-shadow value and get its layers back as sliders, with honest parse errors.
- 100% private: the preview is your browser rendering the CSS — nothing is uploaded.
Common Use Cases
- A product card: the soft-card preset (0px 8px 24px 0px rgba(0, 0, 0, 0.15)) — no horizontal shift, 8px drop, blur about three times the drop, low opacity.
- A dashboard panel: Material elevation 3 — two layers, a close contact shadow and a soft ambient one.
- A modal: Material elevation 5 — the highest standard elevation, clearly above the surface.
- A neumorphic control: two opposite shadows on a same-colour surface — dark down-right, light up-left.
- A keyboard-focus ring: 0 0 0 3px in the accent colour at 50% opacity — visible without changing layout.
- Debugging a shipped shadow: paste the declaration into edit-existing mode and see each layer as sliders.
Developer Notes & Best Practices
One settings object drives both the preview and the output: the preview card's inline style is the layers joined with commas, and the CSS tab is the same layers formatted one per line — so the output always matches what you see. Colour and opacity merge into rgba(): a #rrggbb colour plus an opacity becomes rgba(r, g, b, opacity), including 3-digit hex expansion and 8-digit hex parsing on the way back in. The Tailwind output replaces spaces with underscores and keeps commas, which are legal inside an arbitrary value: shadow-[0px_8px_24px_0px_rgba(0,_0,_0,_0.15)]. The parser splits on top-level commas only — commas inside rgba() parentheses do not split layers — then reads each layer as optional inset, two to four px lengths, and an optional trailing colour (rgba()/rgb()/#hex, including 8-digit hex with alpha). Anything else — em/rem lengths, named colours, missing lengths — returns a named error for that layer instead of a silent wrong answer. Preset values are fixed and published: the layered-soft preset is five layers doubling offset and blur (1/2, 2/4, 4/8, 8/16, 16/32) at 6% opacity each; the Material presets follow the standard elevation ladder; the focus ring is 0 0 0 3px rgb(59 130 246 / 0.5). The preview card is a white (light mode) or slate-800 (dark mode) box; the checkerboard is a 16px two-tone grid. The border-radius slider sets the preview box's radius only — it is not part of the shadow output.
The five values, in fixed order
| Value | What it does | Typical range |
|---|---|---|
| offset-x | Horizontal shift — positive moves the shadow right | -100px to 100px |
| offset-y | Vertical shift — positive moves the shadow down | -100px to 100px |
| blur | How soft the edge is — 0 is a hard edge | 0px to 200px |
| spread | How much the shadow grows (positive) or shrinks (negative) | -100px to 100px |
| colour | The shadow colour, with opacity merged into rgba() | black at 6–20% for cards |
Material elevation 1–5 (the presets on this page)
| Elevation | Layers | Feels like |
|---|---|---|
| 1 | 0 1px 3px, 20% | A resting card |
| 2 | 0 3px 6px, 16% | A card with a little lift |
| 3 | 0 3px 6px + 0 8px 16px | A raised panel |
| 4 | 0 6px 12px + 0 16px 32px | A floating panel |
| 5 | 0 10px 20px + 0 24px 48px | A modal or dialog |
- Blur about three times the drop: 8px down wants about 24px of blur. Equal blur and offset looks like a smudge.
- Keep card-shadow opacity low — 6–20% black. A shadow darker than the surface it sits on reads as dirt, not depth.
- Layer for softness: one tight contact layer plus one wide ambient layer beats one compromise layer.
- Tune the shadow on the background it will sit on — check all three preview backgrounds, especially dark.
- Use inset only for pressed surfaces: an inset shadow reads as recessed, never as raised.
- Animate hover shadows with a ::after layer's opacity, never by animating box-shadow itself — the repaint cost makes the transition janky.
Common Mistakes
- Equal blur and offset: a shadow with 8px down and 8px blur looks like a smudge, not a shadow — blur should be about three times the drop.
- One layer doing two jobs: a single shadow cannot be both tight and soft — layer a contact shadow and an ambient shadow.
- Tuning on white and shipping on dark: a black shadow that reads on white nearly vanishes on dark grey.
- Using box-shadow on a transparent PNG and wondering why the shadow is a rectangle — that shape needs drop-shadow().
- Animating box-shadow on hover: the browser repaints the shadow every frame, so the transition stutters — animate a ::after layer's opacity instead.
- Forgetting layer order: the first layer paints on top, so the tight contact shadow goes first and the soft ambient shadow after it.
Limitations
box-shadow follows the element's box and border-radius. Shadows that must follow visible pixels — a transparent PNG, an SVG shape, a clipped element — need filter: drop-shadow(), which has no spread and no inset; this page does not emit drop-shadow(). Animating box-shadow directly is expensive: the page emits the shadow, not the animation, and documents the ::after-opacity pattern instead. The Tailwind output is an arbitrary value, not a named utility: reuse means adding it to the theme (--shadow-card in Tailwind v4, theme.extend.boxShadow in v3), and the class names were checked against documented Tailwind v4, not by compiling a Tailwind project. The edit-existing parser handles px lengths and rgba()/rgb()/#hex colours only — em/rem lengths and named colours are reported as unparseable, not guessed. The preview box's corner radius is a preview control only; it is not part of the copied CSS.
Structured Input/Output Example
Preset: Soft card — one layer, offset 0/8, blur 24, spread 0, black at 15% opacity
box-shadow: 0px 8px 24px 0px rgba(0, 0, 0, 0.15); Tailwind: shadow-[0px_8px_24px_0px_rgba(0,_0,_0,_0.15)]
Related Tools
CSS Flexbox Generator
CSS flexbox generator: build layouts visually — presets, live preview, container and per-item controls, clean CSS + HTML and Tailwind v4 output. No signup.
CSS Grid Generator
CSS grid generator: build layouts visually — per-track sizing, named areas, presets, live preview, clean CSS + HTML and Tailwind v4 output. No signup.
CSS Gradient Generator
CSS gradient generator with linear, radial, conic and mesh/aurora gradients — live preview, presets, Tailwind output and PNG export. 100% offline.
Color Converter
Color converter: translate colors between HEX, RGB, HSL and OKLCH with a live preview swatch. Type a hex code or pick visually, then copy clean CSS.