CSS Box Shadow Generator

Build single and multi-layer box shadows visually. Adjust offsets, blur, spread, color, and opacity — then copy the CSS.

Layers
Generated CSS
Adjust the sliders to design your box shadow.

How to Use the Box Shadow Generator

  1. Choose a mode — Outer for standard drop shadows, Inset for inner shadows, Layered to build up multiple shadows, or Presets for ready-made effects.
  2. Adjust the sliders — Offset X and Y move the shadow position. Blur controls softness. Spread expands or contracts the shadow size.
  3. Set the color — pick a shadow color and use the opacity slider to make it transparent. Dark semi-transparent shadows look most natural.
  4. Add layers in Layered mode to stack multiple shadows for depth and dimension.
  5. Copy or download the CSS and paste it into your stylesheet.

Understanding CSS box-shadow

The CSS box-shadow property is one of the most versatile styling tools available. It adds shadow effects around an element's frame, creating the illusion of depth and elevation on a flat screen. Unlike images or SVG, box shadows are rendered by the browser at any resolution, scale with the element perfectly, and require zero extra HTTP requests.

The Five Parameters

  • offset-x — horizontal shadow position. Positive moves right, negative moves left.
  • offset-y — vertical shadow position. Positive moves down, negative moves up.
  • blur-radius — shadow sharpness. 0 is a hard edge; higher values produce softer shadows.
  • spread-radius — shadow size beyond the element's dimensions. Negative values create a smaller shadow for more realistic lighting.
  • color — any valid CSS color. Semi-transparent rgba() colors produce the most natural results.

The Inset Keyword

Adding inset before the offsets flips the shadow to the inside of the element. Inset shadows are used to simulate pressed button states, create inner glow effects, and add subtle depth to input fields. When combined with outer shadows, they can create very convincing neumorphic or embossed effects. Note that inset shadows are clipped to the element's border-box, so they respect the element's border-radius.

Layered Shadows for Depth

Real-world objects cast complex shadows — a small, dark shadow close to the object for contact, and a larger, lighter shadow for ambient light. Material Design formalized this with its elevation system, which uses multiple shadow layers at each depth level. A typical Material card shadow uses two layers: a small, sharp shadow for the key light, and a larger, diffuse shadow for ambient light. This technique produces shadows that look believable at any background color. Use the Layered mode in this generator to experiment with multi-layer compositions.

Popular Shadow Presets Explained

  • Material: Two-layer system using very dark rgba shadows — one sharp for direct light, one soft for ambient
  • Soft: Large blur, minimal offset, low opacity — used in modern card designs and modals
  • Sharp: Zero blur radius — crisp, geometric shadows like print design
  • Neon: Colored shadow matching the element's background color — creates a glowing halo effect
  • Glassmorphism: Subtle inner glow combined with a soft outer shadow — pairs with backdrop-filter blur

Performance Considerations

Box shadows are GPU-accelerated in modern browsers, but very large or blurry shadows on many elements can still affect rendering performance, especially during animations. If you are animating box shadows, consider using opacity or transform transitions instead, with pseudo-elements that already have the shadow applied. This avoids triggering layout recalculation on each frame. For text elements, use the text-shadow generator instead — it follows the text shape rather than the element box.

Frequently Asked Questions

The full CSS box-shadow syntax is: box-shadow: offset-x offset-y blur-radius spread-radius color. For example: box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1). You can add the 'inset' keyword at the start to create an inner shadow. Multiple shadows can be combined with commas.
blur-radius controls how blurry or sharp the shadow edge is. A value of 0 produces a hard, crisp shadow. Larger values produce softer, more diffused shadows. spread-radius expands or contracts the shadow itself before blurring. A positive spread makes the shadow larger than the element; a negative spread makes it smaller.
Add the 'inset' keyword to the beginning of the box-shadow value, before the offsets. For example: box-shadow: inset 0 2px 4px rgba(0,0,0,0.2). Inset shadows appear inside the element's border box instead of outside, useful for creating pressed button effects or inner glow effects.
Separate multiple shadow definitions with commas. For example: box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24). Each shadow is rendered in order — the first shadow appears on top. This technique is used in Material Design and glassmorphism effects to create layered depth.
box-shadow applies to the element's rectangular box, ignoring transparent areas. filter: drop-shadow follows the actual shape of the content, including transparent PNG images and SVG paths. For rectangular elements, they look identical. For irregularly shaped elements or icons, drop-shadow produces a more natural result.