Back CSS

CSS Box Shadow Generator

This CSS box shadow generator builds production-ready shadows with visual sliders for offset, blur, spread, color and the inset keyword. Stack unlimited shadow layers to create Material-style elevations, neumorphic surfaces, neon glows, or soft ambient lighting. Every change updates the live preview and rewrites the CSS in real time, so you can copy the finished declaration straight into your stylesheet. Pick a preset to start fast, or dial in custom values on both axes. All calculation runs in your browser — no sign-up, no tracking, works offline once the page is cached.

Last updated: May 2026 · Reviewed by FreeDevTool design engineering team
0px
8px
24px
0px
Copied!

Box-shadow in 2026 — anatomy, layered shadows, and the design-system patterns that ship

The box-shadow property is one of the oldest CSS3 features — yet good shadows still distinguish a polished interface from one that looks like a wireframe. This guide unpacks the syntax (each of the four numeric values does something specific), the physics-aware patterns Google's Material team and Apple's Human Interface team use to build elevation systems, the new filter: drop-shadow() alternative for irregular shapes, and the performance pitfalls that cause shadow-heavy pages to drop frames during scroll.

The four numbers — what each value actually does

The full box-shadow grammar from CSS Backgrounds and Borders Module Level 3:

box-shadow: [inset?] <offset-x> <offset-y> [blur-radius] [spread-radius] [color];
ValueEffectDirection of "+"
offset-xHorizontal shiftPositive = shadow to the right
offset-yVertical shiftPositive = shadow below the element
blur-radiusHow soft the edge is0 = hard edge; large = diffuse
spread-radiusGrow / shrink before blurPositive = bigger; negative = inset-clipped
colorShadow color (any CSS color)Default = current text color
insetPaint inside the boxDefault is outer (drop) shadow

The blur and spread interact in non-obvious ways. A 24 px blur with 0 spread creates a 24-pixel-wide gradient on each edge. A −12 px spread with a 24 px blur shrinks the source rectangle first, so you only see the right half of the gradient — useful for tight inner-glow effects.

Layered shadows — why the best shadows are three shadows

Real-world shadows are not a single blur. A pen on a desk in a sunlit room casts:

  1. A contact shadow — sharp, dark, right under the object.
  2. A key shadow — a softer mid-distance shadow from the dominant light source.
  3. An ambient shadow — a wide, very soft shadow from indirect light bouncing around the room.

Material Design and Apple's HIG both encode this in their elevation systems. A typical 8-dp Material card:

box-shadow:
  0  1px  2px rgba(0,0,0,.10),  /* contact */
  0  4px  8px rgba(0,0,0,.08),  /* key */
  0 12px 24px rgba(0,0,0,.06);  /* ambient */

The pattern is: progressively bigger offset and blur, progressively lower opacity. Designers call the result "smell of money" — UIs that feel premium without anyone being able to articulate why.

Material Design elevation, in CSS form

The Material 3 elevation tokens, translated to CSS box-shadow:

LevelUse forBox-shadow
0Flat surfaces, app bar at restnone
1Cards, switches, raised buttons0 1px 2px rgba(0,0,0,.30), 0 1px 3px 1px rgba(0,0,0,.15)
2FAB rest, snackbars0 1px 2px rgba(0,0,0,.30), 0 2px 6px 2px rgba(0,0,0,.15)
3FAB hover, navigation drawer0 1px 3px rgba(0,0,0,.30), 0 4px 8px 3px rgba(0,0,0,.15)
4Dialogs, picked-up items0 2px 3px rgba(0,0,0,.30), 0 6px 10px 4px rgba(0,0,0,.15)
5Modal overlays0 4px 4px rgba(0,0,0,.30), 0 8px 12px 6px rgba(0,0,0,.15)

Neumorphism — the two-light pattern

Soft-UI / neumorphic surfaces look extruded out of the background. The trick: two opposing shadows, one lighter than the surface, one darker.

background: #e0e5ec;
box-shadow:
  9px  9px 18px #a3b1c6,    /* darker, bottom-right */
 -9px -9px 18px #ffffff;    /* lighter, top-left */

Neumorphism died as a mainstream trend around 2022, partly because the low-contrast aesthetic is an accessibility nightmare. Use it for marketing pages and design portfolios where contrast is decorative; do not ship it in transactional UI.

Inner shadows for inputs, pressed buttons, and depth

The inset keyword paints the shadow inside the box. Use cases:

box-shadow vs filter: drop-shadow() — when to use each

Aspectbox-shadowfilter: drop-shadow()
Shape followedBox (with border-radius)Actual painted shape (incl. transparent PNG / SVG cut-outs)
Spread radiusYesNo
Inset shadowsYesNo
Multiple shadowsComma-listChain drop-shadow() calls
PerformanceLower GPU costHigher cost (creates new stacking context)
Best forCards, buttons, rectangles with rounded cornersLogos, SVG icons, irregular shapes, PNG with transparency

Performance — the shadow trap that drops frames

Box-shadows are GPU-accelerated, but each shadow layer creates a paint area equal to the element rectangle plus the shadow extent on every side. A 0 0 100px 100px shadow on a 200×200 box covers 600×600 pixels — nine times the original area. Multiply by stacked layers and you can blow out paint cost on weaker mobile GPUs.

The defensive habits:

Common box-shadow mistakes

Frequently Asked Questions

What does each value in a CSS box-shadow mean?
The box-shadow property takes up to six values: horizontal offset, vertical offset, blur radius, spread radius, color, and an optional inset keyword. Positive h-offset moves the shadow to the right; positive v-offset moves it down. Blur softens the edge — a blur of 0 creates a hard-edged shadow, while larger values create a diffuse gradient. Spread grows or shrinks the whole shadow uniformly before blurring. The inset keyword paints the shadow inside the element instead of outside.
Can I stack multiple box-shadows on one element?
Yes — separate each shadow with a comma inside a single box-shadow declaration. The first shadow renders on top of the next, so layer your sharp, close shadows first and softer, wider shadows after. Stacking is how designers achieve Material Design elevations (typically three layers: ambient, key, and contact), neumorphic surfaces (one light and one dark shadow from opposite directions), and realistic ambient lighting. This generator supports as many layers as you need — use the + Add layer button to create a new one.
What is the difference between inset and outer shadows?
An outer shadow (the default) paints outside the element's border, giving a sense of elevation above the page. An inset shadow paints inside the element, creating a recessed or pressed-in look. Inset shadows are commonly used for input fields, pressed button states, inner glows on cards, and simulating depth inside a container. You can mix inset and outer shadows on the same element by comma-separating them — for example, combining a soft outer shadow with a subtle inset highlight at the top edge creates a convincing "lifted" effect.
Do box-shadows affect layout or performance?
Shadows do not affect layout — they are painted outside the box model and do not push neighboring elements. However, large blur radii or many stacked shadows can hurt paint performance, especially on mobile devices with weaker GPUs. For animated shadows, prefer the will-change: box-shadow hint, or animate a pseudo-element's opacity instead of the shadow property itself to keep the animation on the compositor thread. Avoid animating the blur radius on every frame.
How do I make a soft, realistic shadow?
Realistic shadows use low opacity (rgba alpha between 0.08 and 0.2), a small vertical offset, and a generous blur. Try stacking two or three layers: a tight near shadow for contact with the surface, a medium blur for body depth, and a wide soft blur for ambient light. Avoid pure black — a slightly tinted dark color (for example rgba(17, 24, 39, 0.15)) reads as more natural because real-world shadows pick up ambient color tint. The Paper and Soft presets above demonstrate this layered approach.
Does box-shadow follow border-radius?
Yes. A box-shadow automatically traces the element's border-radius, so a rounded card gets a rounded shadow without any extra work. This is different from filter: drop-shadow(), which follows the actual painted shape including transparent PNG edges. Use box-shadow for rectangular and rounded-rectangular elements; use drop-shadow for irregular shapes, SVG icons, or elements with transparent cut-outs.

Browse all 50 free developer tools

All tools run in your browser, no signup required, nothing sent to a server.