FC

🌑 CSS Box Shadow Generator

Build shadows visually - control every property and copy CSS instantly

Horizontal (X)0px
Vertical (Y)4px
Blur16px
Spread0px
box-shadow: 0px 4px 16px 0px #00000040;

How to Use the Box Shadow Generator

Create realistic CSS box shadows without guessing values. Drag the sliders to see the shadow update live on the preview box. X/Y offsets control shadow direction, Blur controls softness, Spread expands/shrinks the shadow size, and Inset moves the shadow inside the element (useful for pressed/clicked states).

Soft card shadow

box-shadow: 0 4px 16px 0 rgba(0,0,0,0.25);

Inset inner glow

box-shadow: inset 0 2px 8px 0 rgba(0,0,0,0.15);

Tip: Use near-zero X and Y with high Blur (20-30px) and light colour for modern card shadows. Use negative spread to create a shadow that is smaller than the element for a floating effect.

What are the five values in a CSS box-shadow declaration?

box-shadow: [offset-x] [offset-y] [blur-radius] [spread-radius] [color]. offset-x: horizontal offset (positive = right, negative = left). offset-y: vertical offset (positive = down, negative = up). blur-radius: how soft the shadow edge is (0 = hard edge, higher = softer). spread-radius: how much the shadow expands or contracts beyond the element (positive = larger, negative = smaller). color: any CSS color value. Example: box-shadow: 2px 4px 8px -2px rgba(0,0,0,0.2) creates a soft, slightly inset realistic shadow.

What is the inset keyword and when should I use it?

Adding inset makes the shadow appear inside the element rather than outside: box-shadow: inset 0 2px 4px rgba(0,0,0,0.1). Inset shadows are used for pressed button states (makes the button look physically indented), input field focus states (inner glow effect), and sunken panel effects. Combining an outer shadow for default state and an inset shadow for the :active state creates a realistic button press animation without any transform needed. Inset shadows do not contribute to the element's size — they clip to the element's border box.

How do I create layered box shadows for elevation effects like Material Design?

Multiple box-shadows are comma-separated. Material Design uses layered shadows to represent elevation: elevation 2dp = box-shadow: 0 1px 5px rgba(0,0,0,0.2), 0 2px 2px rgba(0,0,0,0.14), 0 3px 1px rgba(0,0,0,0.12). The technique: combine a diffuse ambient shadow (large blur, low opacity) with a sharp directional shadow (small blur, moderate opacity). This mimics real-world lighting where shadows have both a hard shadow from the direct light source and a soft shadow from ambient light.

Why use rgba() for shadow colors instead of hex?

Shadows look most realistic when they are semi-transparent, allowing the background color to show through. rgba(0,0,0,0.15) is a 15% opaque black — it blends with whatever color is behind it. A solid black shadow (#000000) looks harsh and flat on colored backgrounds. A shadow defined as rgba(0,0,0,0.2) looks correct on both white and colored backgrounds. For colored shadows (like a purple card casting a purple shadow), use the card's own color at low opacity: rgba(124,58,237,0.25).

How do I remove a box shadow that was inherited or set by a library?

Set box-shadow: none to explicitly remove all shadows. This overrides inherited shadows and resets library defaults. If you are inside a CSS framework that uses box-shadow on inputs or cards, use the component's modifier class if available, or add box-shadow: none with sufficient specificity. The CSS Specificity Calculator on this site helps determine what specificity level you need to override a library rule.

What is the difference between box-shadow and drop-shadow filter?

box-shadow creates a shadow behind the element's rectangular box (ignoring transparent areas). filter: drop-shadow() creates a shadow that follows the actual rendered shape, including transparent areas in PNGs and SVGs. For a PNG with a transparent background containing a non-rectangular image (like a product photo cutout), drop-shadow follows the actual object outline. box-shadow would create a rectangle shadow behind the whole image element. Performance-wise, box-shadow is GPU-accelerated; drop-shadow filter can be more expensive for complex images.

What other CSS visual tools pair with the Box Shadow Generator?

The CSS Gradient Generator adds depth to elements alongside shadows — gradients and shadows are the two primary depth cues in flat UI design. The Border Radius Generator rounds the corners that the shadow follows. The Color Converter translates Figma shadow color values to rgba() format. The CSS Specificity Calculator helps when you need to override a library's shadow with your own. All are in the Dev Tools CSS section.

Complete Guide

📊 Key Data Points

5 parameters

h-offset, v-offset, blur, spread, color — each independently adjustable

inset keyword

Inner shadows for pressed states and depth effects

Comma-stacked

Multiple shadows separated by commas for realistic multi-layer depth

CSS Box Shadow Generator -- Complete USA Guide 2026

Box shadows add depth and hierarchy to UI elements. The 5-parameter syntax (h-offset v-offset blur spread color) is difficult to visualize mentally, and stacking multiple shadows for realistic elevation requires careful layering.

This generator provides a visual builder with live preview for single and stacked shadows. Runs in your browser.

**Long-tail searches answered here:** css box shadow generator live preview free, multiple stacked box shadows CSS builder online, inset drop shadow CSS code generator browser.

Pair with CSS Gradient Generator and Border Radius Generator.

🔬 How This Calculator Works

Maintains a list of shadow layers. Each layer independently controls h-offset, v-offset, blur radius, spread radius, color (with opacity), and inset toggle. Multiple shadows stack with commas: box-shadow: 0 1px 3px rgba(0,0,0,0.1), 0 4px 8px rgba(0,0,0,0.06). The preview element updates in real time. Negative spread with large blur creates soft shadows that do not extend beyond element bounds.

✅ What You Can Calculate

Multiple shadow layers

Stack shadows for realistic depth effects. Most design system elevations use 2-3 layered shadows at different opacities rather than a single large shadow.

Inset shadow support

Toggle inset for inner shadows — pressed button states, depth on input fields, and inset text effects.

Opacity-aware color

Shadow color uses rgba() to control opacity independently from the hue. Semi-transparent shadows look far more realistic than solid-color shadows.

Copy-ready CSS

Output is the complete box-shadow property declaration — paste directly into your stylesheet.

🎯 Real Scenarios & Use Cases

Design system elevation levels

Build your sm, md, lg, xl elevation shadows here and document them as CSS custom properties for your design system.

Card component styling

Typical card shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24) — adjust until the depth looks right.

Focus ring for inputs

Input focus rings: 0 0 0 3px rgba(59,130,246,0.5) — zero offsets, zero blur, 3px spread. Build the focus ring color to match your brand.

Button press states

Inset shadow on active buttons: inset 0 2px 4px rgba(0,0,0,0.2) creates a pressed appearance.

💡 Pro Tips for Accurate Results

Two shadows for realistic depth. One small dark shadow (nearby) + one large light shadow (ambient): 0 1px 3px rgba(0,0,0,0.2), 0 8px 24px rgba(0,0,0,0.08).

Negative spread to contain blur. 0 4px 16px -4px rgba(0,0,0,0.2) — large blur but negative spread keeps the shadow tight to the element.

Focus rings use zero blur. 0 0 0 3px rgba(59,130,246,0.5) — zero h/v offset, zero blur, 3px spread. Creates an even outline that follows the element border-radius.

Opacity matters more than blur. Decreasing shadow opacity looks more realistic. Real shadows have 10-20% opacity for soft, 30-40% for stronger depth.

🔗 Use These Together

🏁 Bottom Line

The difference between flat and elevated design is often two well-chosen shadow layers. This generator makes the 5-parameter syntax visual. For complete component styling: add gradients with CSS Gradient Generator and round corners with Border Radius Generator.