Skip to main content

CSS Box Shadow Generator

Create CSS box shadows with a visual editor. CSS box-shadow generator, shadow maker and box-shadow builder with live preview, multi-layer support and Material elevation presets.

Reviewed by · Last reviewed

Shadow 1
4px
4px
10px
0px
25%
CSS
box-shadow: 4px 4px 10px 0px rgba(0, 0, 0, 0.25);

How to Use the Box Shadow Generator

  1. Adjust the sliders — X offset and Y offset move the shadow horizontally and vertically; blur softens the edge; spread grows or shrinks the shadow.
  2. Pick a color with the color picker, then set transparency with the opacity slider — semi-transparent shadows look far more natural than solid ones.
  3. Toggle Inset for an inner (pressed-in) shadow instead of an outer drop shadow.
  4. Click "+ Add Shadow" to layer multiple shadows on the same element — essential for realistic depth effects like neumorphism.
  5. Copy the CSS and paste it into your stylesheet. The preview updates live so you know exactly what will render.

About CSS box-shadow

The CSS box-shadow property has been part of CSS3 since 2011 and is supported by every modern browser. Its full syntax is box-shadow: <inset?> <offset-x> <offset-y> <blur-radius?> <spread-radius?> <color>. Only offset-x, offset-y, and color are mandatory; blur defaults to 0 (a hard edge) and spread defaults to 0 (no expansion).

The four numeric values control the shape of the shadow. Offset-x is positive-right, negative-left. Offset-y is positive-down, negative-up — reversed from mathematical convention because CSS y-axis grows downward. Blur radius must be non-negative; larger blur creates softer, more atmospheric shadows. Spread radius can be negative to create shadows smaller than the element (useful for inset floating effects).

Multiple shadows can be applied with a comma-separated list: box-shadow: 0 4px 6px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);. Shadows are rendered back-to-front — the first in the list sits on top. This layering is how realistic depth effects are built: the visible "soft" shadow is often a short, tight shadow plus a longer, more diffuse one combined.

Examples

  • Subtle card shadow: box-shadow: 0 1px 3px rgba(0,0,0,0.1); — the standard card-lift used by most modern UIs.
  • Elevated drop shadow: box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04); — Material-style high-elevation floating panel.
  • Inner shadow (inset): box-shadow: inset 0 2px 4px 0 rgba(0,0,0,0.06); — looks like a pressed-in input field or slot.
  • Glow effect: box-shadow: 0 0 20px rgba(59,130,246,0.5); — no offset, pure blur. Used for focus rings and hover states.
  • Neumorphism: box-shadow: 8px 8px 16px #c8c8c8, -8px -8px 16px #ffffff; — two opposing shadows give a soft "extruded from the background" feel. Works only on a mid-tone background.

CSS Box Shadow Examples by Elevation

Designers often start from a known elevation set rather than guessing offsets. The patterns below cover the most common UI shadow needs and pair well with the CSS gradient generator for surfaces and the text-shadow generator for matching type. Drop them into the live editor above as a starting point and tweak from there.

  • Tailwind shadow-sm: box-shadow: 0 1px 2px 0 rgba(0,0,0,0.05); - subtle depth for inputs and chips.
  • Tailwind shadow (default): box-shadow: 0 1px 3px 0 rgba(0,0,0,0.1), 0 1px 2px -1px rgba(0,0,0,0.1); - card resting state.
  • Tailwind shadow-lg: box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1); - dropdowns and popovers.
  • Tailwind shadow-2xl: box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25); - high-floating modals and dialogs.
  • Material elevation 4: box-shadow: 0 2px 4px -1px rgba(0,0,0,0.2), 0 4px 5px 0 rgba(0,0,0,0.14), 0 1px 10px 0 rgba(0,0,0,0.12); - app bars and raised buttons. The three-shadow stack splits the umbra (sharp), penumbra (medium) and ambient (soft) shadows that real lighting produces.
  • Soft inner shadow: box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), inset 0 -1px 0 rgba(0,0,0,0.1); - "etched" depth on flat backgrounds without going full neumorphic.

Tips and Use Cases

  • Material elevation levels - Google\'s Material Design defines standard elevations at 0, 1, 2, 4, 6, 8, 12, 16, and 24 dp. Higher elevations use a larger blur with a bigger negative Y offset to mimic light from above.
  • Performance — box-shadow is GPU-accelerated on most browsers but can still hurt paint performance on large blur values or when applied to hundreds of elements. Use filter: drop-shadow() for shadows that should follow the alpha shape of SVG or PNG content.
  • Layer for realism — real objects cast more than one shadow. A short, dark shadow plus a longer, lighter shadow almost always looks better than a single large shadow.
  • Use rgba() color — solid black shadows (#000) look harsh and artificial. Try 10-20% opacity black for cards and 30-50% for floating modals.
  • Accessibility — shadows should never be the only indicator of an interactive state. Always pair hover/focus shadows with an outline or color change so keyboard and screen-reader users get the same feedback.
  • Animating shadows is supported (transition: box-shadow 200ms) but expensive. For better perf, animate transform (scale/translate) and toggle shadow via pre-computed classes.

Frequently Asked Questions

What is CSS box-shadow?

The <code>box-shadow</code> property adds shadow effects around an element's frame. It accepts five values: optional <code>inset</code> keyword, horizontal offset, vertical offset, optional blur radius, optional spread radius, and color. Multiple shadows can be comma-separated to stack them. Box-shadow has been supported in every major browser since IE9 (2011), making it safe to use without fallbacks in modern work.

Can I add multiple shadows?

Yes. CSS <code>box-shadow</code> accepts a comma-separated list of shadow values: <code>box-shadow: 0 4px 6px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);</code>. Shadows render back-to-front — the first in the list sits on top of the others. Layering 2-3 shadows with slightly different blurs and opacities produces far more realistic depth than a single large shadow, because real-world objects cast diffuse ambient shadows plus a tighter directional one.

What does the inset keyword do?

The <code>inset</code> keyword moves the shadow inside the element instead of outside it. The visual result is an inner shadow, as if the element were recessed into the page. Common uses include pressed-button states, text input fields, and decorative pits or grooves. You can mix inset and outer shadows in the same multi-shadow declaration — for example, a subtle inset for depth plus an outer shadow for elevation.

What is the spread value?

Spread is the fourth numeric value and controls how much the shadow expands (positive) or shrinks (negative) before the blur is applied. With spread of 0 the shadow matches the element's box size. A spread of 4px grows the shadow box by 4px on every side, which then gets blurred. Negative spread is useful for creating a shadow that appears to "emanate from below" the element without sticking out from the sides.

How is box-shadow different from filter: drop-shadow?

Both create shadow effects, but <code>box-shadow</code> follows the element's rectangular border box, even if the element has rounded corners or a transparent background. <code>filter: drop-shadow()</code> follows the actual alpha shape — essential for SVG icons, PNG images with transparency, or anything non-rectangular. Drop-shadow is slightly more expensive to render but produces correct results on irregular shapes. Use box-shadow for cards and buttons; drop-shadow for logos and icons.

How do I create neumorphism?

Neumorphism ("new skeuomorphism") uses two opposing shadows — one dark, one light — to make elements look softly extruded from a mid-tone background: <code>box-shadow: 8px 8px 16px #c8c8c8, -8px -8px 16px #ffffff;</code>. The technique only works on non-white backgrounds because both the "highlight" and the "shadow" need somewhere to contrast against. Use it sparingly: neumorphic UIs often fail WCAG contrast requirements and are hard to scan quickly.

What are Material Design elevation levels?

Material Design defines a ladder of elevation levels measured in density-independent pixels: 0dp (flat), 1dp (switches), 2dp (cards at rest), 4dp (app bar), 6dp (FAB at rest), 8dp (bottom sheet), 12dp (FAB pressed), 16dp (nav drawer), and 24dp (dialog). Each level has a prescribed umbra (sharp) and penumbra (soft) shadow pair. Using standard elevations keeps an interface visually consistent and signals a stable hierarchy to the user.

Does box-shadow affect performance?

Box-shadow is mostly GPU-accelerated in modern browsers, but large blur radii or hundreds of shadowed elements on-screen can slow paint and compositing, especially on mobile. Animating box-shadow directly triggers repaints. For hover/focus transitions, prefer animating <code>transform</code> (scale or translate) with pre-computed shadow classes, or fade between two absolutely-positioned pseudo-elements that each carry a static shadow - both tricks sidestep repaints.

Is this a CSS shadow maker or a box-shadow generator - what is the difference?

They describe the same thing. "CSS shadow maker", "shadow generator", "box-shadow generator", "box-shadow gen" and "CSS box-shadow generator" are all common search phrasings for a tool that writes the <code>box-shadow</code> declaration for you. This page covers every variant: pick offsets, blur, spread and color visually, stack multiple layers, toggle inset, and copy the resulting shadow CSS into your stylesheet. If you need shadows that follow a non-rectangular alpha shape (SVG icons, PNGs with transparency) use the CSS filter generator with <code>filter: drop-shadow()</code> instead.

Where can I find good CSS box shadow examples to copy?

The "CSS Box Shadow Examples by Elevation" section above lists production-ready snippets for Tailwind shadow-sm through shadow-2xl, Material Design elevation 4, and a soft inner-shadow trick. Each example is one-click pasteable. For surfaces, pair the shadow with a gentle background gradient from the <a href="/tools/gradient-generator/">CSS gradient generator</a>; for matching headings, use the <a href="/tools/text-shadow-generator/">text-shadow generator</a> so depth between containers and type stays consistent.

How do Tailwind shadow classes compare to Material elevation?

Tailwind ships five default shadow scales (sm, default, md, lg, xl, 2xl) that compose two layers each - one tight directional shadow and one soft ambient shadow. Material Design defines a 24-step ladder (0-24dp) that uses three layers (umbra, penumbra, ambient). Tailwind covers ~95 percent of UI needs and is much easier to override; Material is more physically realistic but heavier. For a brand-agnostic SaaS UI, start from Tailwind defaults and only reach for Material when you need true elevation hierarchy (e.g. a multi-pane document editor).

More CSS & Design