What is CSS box-shadow?
The CSS box-shadow property draws a shadow around an element. You set the horizontal and vertical offset, the blur, the spread and the color. Shadows lift cards, buttons and dialogs off the page. Several shadows separated by commas give a softer, more natural depth.
How to use the box shadow generator
- Click a preset, or start from the default shadow.
- Move the sliders for X Offset, Y Offset, Blur, Spread and Opacity.
- Click the swatch under Color to change the shadow color.
- Turn on Inset for an inner shadow. Click + Add Layer for more depth.
- Click Copy to copy the CSS.
Tips for natural shadows
Light in real life comes from above, so use a positive Y offset and a small or zero X offset. Keep the opacity low (10% to 25%) for a soft shadow. Two layers often look better than one: a small, sharp shadow close to the element and a large, blurred one farther away.
Frequently Asked Questions
What is the box-shadow syntax?
The full syntax is box-shadow: [inset] x-offset y-offset blur spread color. Separate several shadows with commas.
What does Inset do?
Inset draws the shadow inside the element. It gives a pressed or sunken look, for example for an input field or a pressed button.
What does Spread do?
Spread makes the shadow larger (positive value) or smaller (negative value) before the blur. At 0, the shadow is the same size as the element.
How do I make a shadow with several layers?
Click + Add Layer. Each layer has its own offset, blur, spread, color and opacity. The CSS joins the layers with commas, which all modern browsers support.
What is the difference between box-shadow and drop-shadow?
box-shadow follows the rectangle of the element. filter: drop-shadow() follows the visible shape, so it works better for PNGs with transparency and for SVG icons.