Preview
Box Shadow Preview
Generated CSS
▶ Test in HTML Viewer

CSS Box Shadow: Complete Guide

The CSS box-shadow property adds one or more shadow effects around an element's box. Shadows are essential for creating depth, elevation and visual separation in modern UI design — buttons, cards, modals, dropdowns and tooltips all rely on them. Unlike image-based shadows, CSS box shadows are crisp at any resolution, load instantly, and can be animated.

Use the generator above to build single or multi-layer shadows visually, then copy the CSS directly into your project.

How to Use This Box Shadow Generator

  1. Add as many shadow layers as you need — Click "+ Add Layer" to stack shadows for realistic depth, neumorphism, or glow effects.
  2. Tune each layer — Use the X/Y offset, blur, spread, opacity and color sliders. Toggle Inset for inner shadows.
  3. Copy the CSS — Hit Copy Code to grab the full multi-layer CSS with all your shadows combined into one declaration.

box-shadow Syntax

box-shadow: offset-x offset-y blur spread color;
box-shadow: inset offset-x offset-y blur spread color;

/* Multiple layers (comma-separated) */
box-shadow:
  0 2px 4px rgba(0,0,0,0.1),
  0 8px 24px rgba(0,0,0,0.15);

Understanding Each Value

offset-x — Horizontal shadow position. Positive moves right, negative moves left.

offset-y — Vertical shadow position. Positive moves down, negative moves up.

blur-radius — How soft the shadow edge is. 0 = sharp. Higher = more diffused.

spread-radius — Expands or contracts the shadow size. Positive = larger than the element. Negative = smaller.

color — The shadow color. Use rgba() to control opacity.

Common Shadow Recipes

/* Subtle card lift */
box-shadow: 0 1px 3px rgba(0,0,0,0.1), 0 4px 12px rgba(0,0,0,0.08);

/* Elevated modal */
box-shadow: 0 8px 32px rgba(0,0,0,0.24), 0 2px 8px rgba(0,0,0,0.12);

/* Soft bottom shadow only */
box-shadow: 0 4px 16px -4px rgba(0,0,0,0.2);

/* Coloured glow */
box-shadow: 0 0 0 1px #7c6fff, 0 0 20px rgba(124,111,255,0.4);

/* Pressed button (inset) */
box-shadow: inset 0 2px 4px rgba(0,0,0,0.3), inset 0 1px 2px rgba(0,0,0,0.2);

/* No shadow (reset) */
box-shadow: none;

Inner Shadow in CSS (Inset Box Shadow)

The inset keyword moves the shadow inside the element boundary — useful for pressed button states, inner glow effects, and UI elements that need to appear recessed into the surface.

/* Input field focus ring using inset */
.input:focus {
  box-shadow:
    inset 0 1px 3px rgba(0,0,0,0.15),
    0 0 0 3px rgba(124,111,255,0.25);
}

/* Inner glow */
.glow-card {
  box-shadow: inset 0 0 30px rgba(124,111,255,0.2);
}

An inner shadow is simply a box-shadow with the inset keyword. To put the inner shadow on only one side, offset it towards that side and use a negative spread equal to the blur, so it doesn’t show on the other edges:

/* Inner shadow on all sides */
box-shadow: inset 0 0 10px rgba(0,0,0,0.5);

/* Inner shadow on the top only */
box-shadow: inset 0 8px 8px -8px rgba(0,0,0,0.5);

/* Inner shadow on the bottom only */
box-shadow: inset 0 -8px 8px -8px rgba(0,0,0,0.5);

/* Inner shadow on the left and right */
box-shadow:
  inset 8px 0 8px -8px rgba(0,0,0,0.5),
  inset -8px 0 8px -8px rgba(0,0,0,0.5);

/* Inner and outer shadow together */
box-shadow:
  inset 0 2px 4px rgba(0,0,0,0.2),
  0 4px 12px rgba(0,0,0,0.15);

Tip: turn on Inset for a layer in the generator above to preview any inner shadow before copying it.

Multi-Layer Shadows for Realism

Real-world objects cast complex shadows with multiple components — a sharp close shadow and a soft diffuse shadow further away. Layering two shadows closely mimics this and produces much more realistic depth than a single layer.

/* Layered realistic shadow (low elevation) */
.card {
  box-shadow:
    0 1px 2px rgba(0,0,0,0.07),
    0 2px 4px rgba(0,0,0,0.07),
    0 4px 8px rgba(0,0,0,0.07);
}

/* High elevation — modal/dialog */
.modal {
  box-shadow:
    0 2px 4px rgba(0,0,0,0.08),
    0 8px 16px rgba(0,0,0,0.1),
    0 24px 48px rgba(0,0,0,0.12);
}

Animating box-shadow

box-shadow can be transitioned, but it is expensive because it triggers a repaint on every frame. For animated hover effects, a performance trick is to pre-render the shadow using opacity: 0 on a pseudo-element and fade that in instead of transitioning box-shadow directly.

/* Simple transition (OK for occasional use) */
.card {
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  transition: box-shadow 0.25s ease;
}
.card:hover {
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

Box Shadow on One Side Only (Bottom, Top, Left or Right)

A normal shadow shows on every side the blur reaches. To show it on one side only, push it out with the offset and pull it back in with a negative spread roughly the size of the blur. The negative spread shrinks the shadow so it can’t peek out of the other three edges.

/* Bottom only */
box-shadow: 0 8px 6px -6px rgba(0,0,0,0.35);

/* Top only */
box-shadow: 0 -8px 6px -6px rgba(0,0,0,0.35);

/* Right only */
box-shadow: 8px 0 6px -6px rgba(0,0,0,0.35);

/* Left only */
box-shadow: -8px 0 6px -6px rgba(0,0,0,0.35);

/* Top and bottom only (two layers) */
box-shadow:
  0 8px 6px -6px rgba(0,0,0,0.35),
  0 -8px 6px -6px rgba(0,0,0,0.35);

Increase the offset to make the shadow longer, and keep the spread at about minus the blur so the sides stay clean. This is the usual way to add a shadow under a sticky header or navbar.

Using box-shadow as a Border or Outline

A shadow with no offset, no blur and a positive spread draws a solid ring around the element. Unlike a real border, it takes up no space, so adding or animating it never shifts the layout.

/* 2px ring outside the element */
box-shadow: 0 0 0 2px #7c6fff;

/* 2px ring inside the element */
box-shadow: inset 0 0 0 2px #7c6fff;

/* Two rings: white gap, then colour */
box-shadow: 0 0 0 2px #fff, 0 0 0 4px #7c6fff;

/* Bottom "border" only */
box-shadow: inset 0 -2px 0 #7c6fff;

Why Is My box-shadow Not Working?

Gradient Box Shadow

box-shadow only accepts a single colour per layer, so it can’t be a gradient. For a coloured, gradient glow, put a blurred gradient behind the element with a pseudo-element:

.card {
  position: relative;
  isolation: isolate;        /* keeps the glow behind this card only */
  border-radius: 16px;
  background: #fff;
}
.card::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: linear-gradient(135deg, #7c6fff, #ff6fb0);
  filter: blur(20px);
  transform: translateY(8px);
}

Box Shadow in Tailwind CSS and React Native

Tailwind CSS includes ready-made shadow-* utilities, and shadow-none removes a shadow. The exact sizes in the scale differ between Tailwind versions, so check the docs for the one you use. Any shadow from this generator works as an arbitrary value, with underscores in place of spaces:

<div class="shadow-[0_8px_24px_rgba(0,0,0,0.12)]">...</div>

React Native traditionally doesn’t use CSS box-shadow. On iOS you set shadowColor, shadowOffset, shadowOpacity and shadowRadius; on Android you set elevation. Newer React Native versions also accept a boxShadow style, so check what your version supports.

Browser Support

box-shadow has been universally supported since 2011 — completely safe to use without prefixes or fallbacks. It respects border-radius, but does NOT follow clip-path shapes (use filter: drop-shadow() for that).

FeatureChromeFirefoxSafariEdge
box-shadow10+4+5.1+12+
inset shadows10+4+5.1+12+
multi-layer10+4+5.1+12+
box-shadow animation26+16+7+12+

Frequently Asked Questions

How do I create a neumorphism shadow in CSS?

Stack two shadows with opposite directions — one dark below-right, one light above-left, both on a background that matches the element. Example: box-shadow: 8px 8px 16px #b8b9be, -8px -8px 16px #ffffff. The element should share the same background color as its parent for the soft, embedded look.

What's the difference between inset and outset box-shadow?

Default (outset) shadows project outward from the element's edge. Adding the inset keyword flips the shadow inward, making the element appear pressed in or recessed. Inset shadows are useful for input field focus rings, pressed button states and recessed UI panels.

How do I make a soft drop shadow?

Use a small Y offset, a large blur radius, and low opacity: box-shadow: 0 8px 24px rgba(0,0,0,0.08). The key is high blur with low opacity. Stack a second tighter shadow for added depth: box-shadow: 0 8px 24px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.06).

Can I animate box-shadow?

Yes, but it's expensive — animating box-shadow forces a repaint every frame. For smooth performance, animate the opacity of a pseudo-element with the shadow on it, or use transform: scale() to fake elevation changes. The Animating box-shadow section above has the optimized pattern.

box-shadow vs filter: drop-shadow — which should I use?

Use box-shadow for rectangular UI elements (cards, buttons, panels) — it's faster and respects border-radius. Use filter: drop-shadow() for irregular shapes — it follows transparent areas in PNGs and clip-path edges, which box-shadow can't do. For most UI work, box-shadow is the right choice.

How do I add multiple shadows to one element?

Comma-separate them in a single box-shadow declaration. Each shadow renders top-down — the first shadow listed appears on top. Layering 2-4 shadows produces realistic depth: a tight inner shadow for the edge plus a wider outer shadow for ambient elevation.

How do I add a box shadow to the bottom only?

Offset the shadow downwards and use a negative spread about the size of the blur, so it can’t show on the other sides: box-shadow: 0 8px 6px -6px rgba(0,0,0,0.35).

Can I use box-shadow instead of a border?

Yes. box-shadow: 0 0 0 2px #7c6fff draws a 2px ring that takes up no space, so it never shifts the layout. Add inset to draw it inside the element instead.

Why is my box-shadow not showing?

The most common causes are a parent with overflow: hidden clipping it, a neighbouring element painted on top, a shadow too faint for the background, or a missing unit such as 4 instead of 4px.

How do I remove a box shadow?

Set box-shadow: none. In Tailwind CSS, use the shadow-none class.

Can a box-shadow be a gradient?

Not directly, because each shadow layer takes one colour. Place a blurred gradient behind the element with a ::after pseudo-element instead.

Need a shadow that follows the actual shape of an element rather than its bounding box? Use our CSS Filter Generator with drop-shadow() instead.

Ready-to-Use Shadow Patterns

Copy-paste shadows for the most common UI components. Paste directly into your project — all use rgba() for compatibility with both light and dark backgrounds.

Card — subtle lift
box-shadow:
  0 1px 3px rgba(0,0,0,.08),
  0 4px 12px rgba(0,0,0,.06);
Modal / Dialog
box-shadow:
  0 8px 32px rgba(0,0,0,.22),
  0 2px 8px rgba(0,0,0,.12);
Button — hover state
box-shadow:
  0 4px 14px rgba(124,111,255,.4),
  0 1px 4px rgba(0,0,0,.12);
Focus ring
box-shadow:
  0 0 0 3px rgba(124,111,255,.3),
  0 1px 3px rgba(0,0,0,.1);
Dropdown / Tooltip
box-shadow:
  0 2px 6px rgba(0,0,0,.1),
  0 8px 24px rgba(0,0,0,.08);
Neon glow (dark UI)
box-shadow:
  0 0 0 1px #7c6fff,
  0 0 20px rgba(124,111,255,.5);
Input — recessed
box-shadow:
  inset 0 1px 3px rgba(0,0,0,.15),
  inset 0 1px 1px rgba(0,0,0,.1);
Layered realistic (3-level)
box-shadow:
  0 1px 2px rgba(0,0,0,.07),
  0 4px 8px rgba(0,0,0,.07),
  0 12px 24px rgba(0,0,0,.07);
Tool last updated: