induwara.lk
induwara.lkDeveloper · Browser-only

Box Shadow Generator — CSS Drop Shadow Builder

Build a CSS box-shadow visually. Drag offset, blur, spread, and colour for each layer, stack up to ten layers, and copy the generated CSS or Tailwind v4 class. Runs entirely in your browser — no upload, no signup.

By Induwara AshinsanaUpdated May 11, 2026
Box shadow generatormulti-layer · live preview
Backdrop

Horizontal — positive moves the shadow right.

Vertical — positive moves the shadow down.

Blur radius. Must be 0 or positive.

Grows (positive) or shrinks (negative) the shadow shape.

5%
Presets

Sources: W3C CSS Backgrounds 3 §7.1 · MDN box-shadow · verified 2026-05-11

How it works

The tool keeps every box-shadow as a structured list of layers in memory. A layer is six values: horizontal offset, vertical offset, blur radius, spread radius, colour, and an inset flag. Every time you change a slider or a colour, the layer list is re-serialised to a CSS box-shadow value via a pure local module. The same string is fed into the preview swatch's inline style and into the read-only output box, so what you see is exactly what you copy.

Grammar. The CSS Backgrounds and Borders Module Level 3 §7.1 defines the property as: box-shadow: none | <shadow># ; and each shadow as inset? && <length>{2,4}&& <color>?. The lengths are, in order: offset-x, offset-y, blur-radius, spread-radius. blur-radius and spread-radius both default to 0 when omitted. Multiple shadows are comma-separated, painted back-to-front in the order they appear — the first shadow in the value sits on top.

Blur vs spread.Blur applies a Gaussian softening of the shadow edge. The exact algorithm is not normative — browsers use slightly different blur kernels — but every modern engine produces a visually similar fall-off. The spec requires blur-radius to be non-negative; this generator rejects negatives at input time with a specific error rather than letting the renderer silently clamp them. Spread is a hard size change: the shadow shape is grown (positive) or shrunk (negative) by the spread amount in every direction before the blur is applied. Negative spread is the trick behind “Material Design”-style shadows that hug the element on the sides but pool deeply under the bottom edge.

Inset. Prefix the keyword inset and the shadow is painted inside the box rather than outside. Inset shadows are clipped to the padding edge so they don't bleed into child elements. The most common patterns are a recessed input field (subtle inset shadow below the top edge) and a hard inner ring (zero offset, zero blur, positive spread, opaque colour). Inset and non-inset shadows can be mixed in the same value.

Multi-layer realism. A single shadow with a large blur fakes softness poorly because the edge density is uniform. Naturalistic shadows from a diffuse light source have a continuous fall-off — brighter near the casting object, fainter farther away. Stacking several shadows with progressively larger blurs and slightly lower opacities samples that curve. The default preset on this page is a six-layer stack that produces a believable elevation on a card-style element.

Output formats. The generator emits three: the full box-shadow: declaration ready to paste into a stylesheet, the value-only form ready to drop into a styled-component or inline style attribute, and a Tailwind v4 shadow-[…]arbitrary value. The Tailwind path replaces spaces with underscores per Tailwind's escaping rule so the class string round-trips through the v4 just-in-time bundler.

Every output is silently round-trip verified on load — the eight built-in presets are serialised, parsed back via a small companion parser, and compared layer-by-layer. The badge in the editor header confirms the check passes. Same credibility check shipped with the CSS gradient generator and JSON formatter elsewhere on this site.

Worked examples

Subtle elevation — Material z=1

Two layers: a soft ambient shadow plus a slightly harder direct shadow.

  1. Layer 1: 0 1px 3px 0 rgba(0, 0, 0, 0.12)
  2. Layer 2: 0 1px 2px 0 rgba(0, 0, 0, 0.24)
  3. CSS: box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.12), 0 1px 2px 0 rgba(0, 0, 0, 0.24);
  4. Notes: Approximates Material Design z=1. The first layer fills the ambient occlusion, the second adds direct contact contrast.

Deep card with negative spread

A single floaty drop shadow that doesn't bleed past the element on the sides.

  1. Offset: X 0, Y 24px
  2. Blur: 48px
  3. Spread: -12px
  4. Color: rgba(13, 42, 86, 0.35) (sapphire @ 35%)
  5. CSS: box-shadow: 0 24px 48px -12px rgba(13, 42, 86, 0.35);
  6. Notes: Negative spread tightens the shadow rectangle before the blur, so it pools under the bottom edge without leaking on the left and right.

Inset hard ring — focus outline

Edge case: zero blur, positive spread, opaque colour. Renders as a hard inner border without taking layout space.

  1. Offset: X 0, Y 0
  2. Blur: 0
  3. Spread: 2px
  4. Color: #1A4FB8
  5. Inset: yes
  6. CSS: box-shadow: inset 0 0 0 2px #1A4FB8;
  7. Notes: Pattern used for focus rings that don't shift surrounding layout — the shadow is purely visual.

Smooth six-layer elevation (default preset)

Stacking layers with doubling blurs samples a continuous shadow fall-off — much more realistic than one big blur.

  1. Layer 1: 0 1px 1px 0 rgba(13,42,86,0.055)
  2. Layer 2: 0 2px 2px 0 rgba(13,42,86,0.055)
  3. Layer 3: 0 4px 4px 0 rgba(13,42,86,0.055)
  4. Layer 4: 0 8px 8px 0 rgba(13,42,86,0.055)
  5. Layer 5: 0 16px 16px 0 rgba(13,42,86,0.055)
  6. Layer 6: 0 32px 32px 0 rgba(13,42,86,0.055)
  7. Notes: Each layer doubles the blur and offset of the one above. The cumulative effect is a smooth, naturalistic shadow with no visible banding.

Frequently asked questions

Sources & references

Specifications last reviewed on 2026-05-11. CSS Backgrounds Module Level 4 is a Working Draft; when proposed changes around shadow grouping and interpolation land in REC, this page is re-verified.

Related tools

Rate this tool
Be the first to rate

Comments & feedback

Spotted a bug or want an improvement? Tell us — our team reviews every comment, and good ideas get built. Comments are public and anonymous.

Found a bug, edge case, or want to suggest an improvement?

Email me at [email protected] — most fixes ship within 24 hours.