🔲 CSS Box Shadow Generator
Visually build CSS box-shadow with live preview. Multiple layers, inset, presets, and one-click CSS copy.
Presets
Shadow Layers
Preview Box
CSS Code
CSS Box Shadow Explained — How to Add Depth and Dimension to Your Designs
The CSS box-shadow property is one of the most versatile tools for creating depth, emphasis, and visual hierarchy in web design. Whether you need a subtle card elevation or a bold neon glow, understanding how box shadows work lets you craft polished interfaces without relying on image assets.
Understanding the CSS box-shadow Property
- Syntax overview — The full syntax is
box-shadow: [inset] offset-x offset-y blur-radius spread-radius color;. Only the two offset values are required; blur, spread, and color are optional. - Offset-x & offset-y — Control the horizontal and vertical position of the shadow. Positive values move the shadow right and down; negative values move it left and up.
- Blur-radius vs. spread-radius — Blur softens the edge of the shadow over a distance, while spread expands or contracts the shadow shape before blurring. A zero-blur, positive-spread shadow produces a sharp outline.
- The inset keyword — Placing
insetat the start renders the shadow inside the element, useful for pressed-button states and inner-glow effects. - Multiple shadows — Comma-separate multiple values to layer shadows. The first listed shadow renders on top, allowing complex depth and lighting effects in a single property.
Box Shadow Design Patterns
- Subtle elevation (Material Design) — Use a small Y-offset with moderate blur and low-opacity black, e.g.
0 2px 8px rgba(0,0,0,0.12), to lift cards off the page. - Hard / no-blur shadows — Set blur and spread to zero for a solid offset shadow. This retro or brutalist style pairs well with bold colors and sharp typography.
- Neumorphism — Combine a light outer shadow with a dark inset shadow (or vice-versa) on a matching background color to create a soft, extruded look.
- Glowing / neon effects — Use zero offsets with a large blur and a vivid color, e.g.
0 0 20px #0ff. Layering two glows of different sizes intensifies the effect. - Layered shadows for realism — Stack two or three shadows with increasing blur and offset to mimic how real-world objects cast diffused light at different distances.
Performance and Accessibility Considerations
Box shadows are GPU-composited in most modern browsers and rarely cause performance issues for typical use. However, extremely large blur radii on oversized elements or during frequent repaints (animations, scrolling) can trigger jank. For animated shadows, prefer transitioning opacity on a pseudo-element rather than the shadow values themselves. Use the prefers-reduced-motion media query to simplify or disable shadow animations for users who opt out of motion. When shadowing non-rectangular shapes like images with transparency, filter: drop-shadow() follows the alpha channel and may be a better fit than box-shadow.
Frequently Asked Questions
box-shadow: [inset] offset-x offset-y blur-radius spread-radius color;. Multiple shadows are comma-separated.