Menu

CSS Box Shadow Generator

Design multi-layer CSS box-shadow with a live preview and copy production-ready CSS.

Last updated

Presets
Preview
Shadow layers
X offset0px
Y offset8px
Blur24px
Spread0px
Opacity0.18
Color
CSS
box-shadow:
    0px 8px 24px 0px rgba(0, 0, 0, 0.18);

What is a CSS box-shadow generator?

box-shadow is the CSS property that adds drop shadows, glows, and inset wells to any element. It is the single biggest lever for giving a flat design a sense of *elevation* - cards lift off the page, modals float above content, buttons feel pressable.

The trick is that a *good* shadow is rarely one layer. Real-world shadows are softer and have ambient bounce - most design systems (Material, iOS, Tailwind) stack 2–3 box-shadow declarations with different offsets and opacities. Hand-writing those is fiddly; a generator lets you tune each layer visually and see the combined result live.

Coddy's generator supports unlimited layers, both *outer* and *inset* shadows, color and opacity per layer, and presets covering the most common patterns: subtle cards, sharp drops, brand glows, inset wells, and neumorphic surfaces. Copy the CSS and paste it straight into your stylesheet - no upload, no account, no watermark.

What to know about CSS box-shadow

  • The syntax is box-shadow: [inset] <x> <y> <blur> <spread> <color>. inset puts the shadow *inside* the element; without it the shadow falls outside.
  • *Blur* softens the edge - larger values produce a more diffuse shadow. *Spread* grows or shrinks the shadow before the blur is applied (negative values pull it in, useful for soft inner lifts).
  • Multiple shadows are comma-separated and stack from back to front in the order written - the first listed sits *underneath* later ones in the final composite.

How to design a box-shadow

  1. Start with a preset

    Pick a preset that matches the feeling you want - subtle card, soft elevation, sharp drop, brand glow, inset well, or neumorphic. The presets are good starting points you can tune.

  2. Tune the active layer

    Drag the sliders for X/Y offset, blur, spread, color, and opacity. The preview on the left updates live. Lower opacity and higher blur read as *softer* shadows.

  3. Stack additional layers

    Click *Add layer* to stack a second shadow. Real-world depth almost always uses two layers: one short and tight (the contact shadow) and one long and soft (the ambient shadow).

  4. Toggle inset for inner wells

    Turning on *Inset* paints the shadow inside the element instead of around it. Combine with a subtle outer shadow for a pressed-button effect.

  5. Copy the CSS

    When the preview matches your design, click *Copy CSS*. Paste the result into your stylesheet - the generated rule includes every active layer.

Box-shadow quick reference

Each value in box-shadow: x y blur spread color and the role it plays.

ValueEffectTypical range
X offsetPushes shadow horizontally; positive = right−40px to 40px
Y offsetPushes shadow vertically; positive = down0px to 40px for natural light
BlurSoftens the edge of the shadow0px to 80px
SpreadGrows or shrinks before blur is applied−30px to 30px
ColorAny CSS color, but rgba() lets you tune opacity per layerrgba(0,0,0,0.05–0.3) for natural shadows
insetPaints the shadow inside the element-
Multiple layersComma-separated; stack from back to front2–3 layers gives realistic depth

Box-shadow examples to try

Subtle card with contact + ambient layers

Two-layer subtle card
box-shadow:    0 1px 2px rgba(0, 0, 0, 0.06),    0 4px 12px rgba(0, 0, 0, 0.08);

A tight low-blur shadow defines the contact point, and a longer softer shadow gives the impression of ambient light. This is the pattern most modern design systems use.

Brand glow

Soft colored glow
box-shadow: 0 0 24px 4px rgba(108, 140, 255, 0.45);

Set X and Y to zero so the glow radiates evenly. A small positive spread thickens the glow before the blur softens it. Use sparingly - colored glows draw a lot of attention.

Pressed inset

Inset shadow for a pressed look
box-shadow:    inset 0 2px 6px rgba(0, 0, 0, 0.18),    inset 0 0 0 1px rgba(0, 0, 0, 0.06);

Inset shadows paint inside the element. One soft shadow gives the impression of a recessed well; a hairline inset adds a subtle inner border for definition.

Common box-shadow mistakes

  • Using pure black at high opacity. It reads as a hard cutout, not a shadow. Drop opacity to 0.06–0.18 for natural-looking elevation.
  • Forgetting the Y offset. A shadow with X=0 and Y=0 sits *behind* the element evenly - fine for a glow, wrong for a card that should look like it's floating.
  • Stacking too many layers. Three is usually plenty; ten produces a muddy, blurry mess and a noticeable paint cost.

CSS Box-Shadow FAQ

What does each box-shadow value mean?
box-shadow: x y blur spread color. The first two are offsets; *blur* softens the edge; *spread* changes the size before blur; the color is any CSS color (use rgba() for opacity control). Add inset at the start to put the shadow inside the element.
How do I stack multiple shadows in one rule?
Separate each shadow with a comma. They render back-to-front in the order written, so the first declared shadow ends up *underneath* later ones. Use this to combine a tight contact shadow with a soft ambient one.
What is the difference between box-shadow and filter: drop-shadow()?
box-shadow follows the element's bounding rectangle and is fast to paint. drop-shadow() follows the alpha channel of whatever it is applied to (great for SVGs and transparent PNGs) but costs more to render. Use box-shadow for cards and buttons; use drop-shadow() for irregular shapes.
Why does my shadow look pixelated?
Either the blur is very small (a 0-px blur is a sharp shadow by design) or the element is being scaled. Increase the blur value or check for a transform: scale() somewhere up the tree.
Does box-shadow affect layout?
No. Shadows are painted outside the element's box but do not push neighboring content. If you need the parent to leave room for the shadow, give the parent padding or overflow: visible.

Learn more

Other developer tools

Coddy programming languages illustration

Learn to code with Coddy

GET STARTED