What Is a CSS Box Shadow?
The CSS box-shadow property adds one or more shadows around an element's frame. Shadows create depth and hierarchy: a card with a shadow appears to float above the page, a raised button looks clickable, and a modal dialog feels like it sits on top of everything else. Used well, shadows make interfaces feel tactile and organised. Used badly, with dark, hard, oversized shadows, they make designs look dated and heavy.
This box shadow generator lets you design shadows visually and see the result instantly, then copy clean CSS. It supports every part of the property, including unlimited layers, which is the secret behind the soft, realistic shadows in modern design systems.
How to Use the Box Shadow Generator
- Pick a preset as a starting point, or adjust Layer 1 directly.
- Set the offsets. Horizontal moves the shadow right (positive) or left, and vertical moves it down or up.
- Adjust the blur for softness and the spread to grow or shrink the shadow.
- Choose the colour and opacity. Low opacity (5–25%) looks most natural.
- Add layers for depth, or tick Inset for an inner shadow.
- Match your design with the box colour, background and corner radius, then copy the CSS.
box-shadow Syntax
box-shadow: [inset] offset-x offset-y blur-radius spread-radius color;
| Value | What it does | Example |
|---|---|---|
| inset | Draws the shadow inside the element | inset 0 2px 4px |
| offset-x | Horizontal distance (negative = left) | 4px |
| offset-y | Vertical distance (negative = up) | 10px |
| blur-radius | How soft the edge is (0 = sharp) | 30px |
| spread-radius | Grows (+) or shrinks (−) the shadow | -5px |
| color | Usually a transparent black or tinted colour | rgba(15, 23, 42, 0.18) |
Separate multiple shadows with commas. The first one listed is drawn on top.
Secrets of Great-Looking Shadows
- Light comes from above. Use a positive vertical offset and little or no horizontal offset.
- Use low opacity. Real shadows are subtle, and 8–20% opacity usually looks best.
- Layer them. Stacking two to five shadows with increasing offset and blur (as in the "Layered smooth" preset) mimics how real light behaves: a tight, dark contact shadow plus a large, faint ambient shadow.
- Negative spread keeps a big blurred shadow tucked under the element, so it doesn't bleed out at the sides.
- Tint your shadows with the background's hue (e.g. dark navy instead of pure black) for a richer, more natural look.
- Be consistent. Define a small elevation scale (such as sm, md, lg and xl) and reuse it across your interface.
Popular Shadow Styles
- Material elevation: Google's Material Design uses paired shadows to represent heights from 1dp to 24dp. The Elevation presets follow the same idea.
- Neumorphism: soft UI made from a light shadow on one side and a dark shadow on the other, on an element the same colour as its background. It's striking, but check the contrast of buttons carefully.
- Brutalist: hard, solid, offset shadows with zero blur for a bold, retro, graphic look.
- Glow: zero offset with a coloured, blurred shadow, for focus states, neon effects and dark-mode highlights.
- Outline ring: zero blur with a positive spread draws a border that doesn't affect layout. It's ideal for accessible focus indicators.
Performance Tips
Box shadows are cheap to draw once, but very large blur radii on many elements, or animating box-shadow directly, can cause jank. To animate a shadow on hover smoothly, put the shadow on a pseudo-element and animate its opacity instead.
Shadows in Dark Mode
Shadows are much less visible on dark backgrounds. In dark themes, show elevation with lighter surface colours (a higher layer uses a slightly lighter grey), and keep shadows darker and more opaque, or replace them with subtle borders.
Drag the Light Source
Instead of adjusting offsets number by number, drag the ☀ light in the preview. Every shadow layer turns to point away from the light, and moving the light further from the box makes the shadows longer, just like a real lamp. Layered shadows keep their relative proportions, so smooth multi-layer presets stay realistic as you move the light. Keyboard users can focus the light and use the arrow keys.
Frequently Asked Questions
How do I add a shadow on only one side?
Use an offset towards that side with a negative spread equal to the blur, e.g. 0 8px 6px -6px rgba(0,0,0,.3) for the bottom only.
What's the difference between box-shadow and drop-shadow?
box-shadow follows the element's rectangle (and border-radius). filter: drop-shadow() follows the actual shape, including transparent PNGs, but has no spread or inset.
Does box-shadow affect layout?
No. Shadows don't take up space or move other elements.
How many shadows can I stack?
As many as you like. Three to five is typical for smooth shadows.
How do I use this in Tailwind?
Copy the arbitrary-value class, e.g. shadow-[0_10px_30px_-5px_rgba(15,23,42,0.18)], or add it to theme.extend.boxShadow.