A CSS box shadow generator lets you see a shadow while you design it, instead of guessing at numbers and reloading your page. Move the sliders, and this CSS box shadow generator updates the preview immediately and writes the code for you. You can control the horizontal and vertical offsets, the blur, the spread, the color and the opacity, and you can switch the shadow to the inside of the box. When it looks right, copy one line of CSS into your stylesheet. It works in your browser, and there's nothing to install.
How to use the CSS box shadow generator
- Choose a starting preset, or move the sliders.
- Adjust the offsets, blur and spread.
- Pick a shadow color and set its opacity.
- Tick Inset for a shadow inside the box.
- Press Copy CSS and paste it into your stylesheet.
What is the box-shadow property?
The box-shadow CSS property adds shadow effects around an element's frame. A box shadow is described by horizontal and vertical offsets relative to the element, a blur radius, a spread radius and a color. You can also apply several shadows to one element by separating them with commas.
What each value does
| Value | Effect |
|---|---|
| Horizontal offset | A positive value moves the shadow right, and a negative value moves it left |
| Vertical offset | A positive value moves the shadow down, and a negative value moves it up |
| Blur radius | A larger value makes the shadow bigger and lighter. It can't be negative |
| Spread radius | A positive value grows the shadow, and a negative value shrinks it |
| Color | The shadow's color, often with some transparency |
| Inset | Places the shadow inside the box instead of outside |
A worked example
The Medium preset has a horizontal offset of 0, a vertical offset of 10 pixels, a blur of 25 pixels, a spread of −5 pixels and a black shadow at 25% opacity. The code that it produces is box-shadow: 0px 10px 25px -5px rgba(0, 0, 0, 0.25);. The vertical offset pushes the shadow below the box, as if light were coming from above. The negative spread pulls in the edges, which makes the box appear to float.
Tips for natural-looking shadows
- Keep the opacity low. Real shadows are rarely solid black.
- Use one light direction across your whole design, so that every shadow agrees.
- Combine a larger blur with a negative spread for a soft, floating look.
- Tint your shadows. On a colored background, a darker shade of that color can look better than black.
- Use bigger shadows for higher objects. A modal window should appear to float above a card.
- Don't overuse them. If everything has a shadow, nothing stands out.
Using shadows to show depth
Design systems often use a small set of shadow levels to indicate how high an element appears to sit above the page. A card at rest might have a soft shadow, a card being hovered over might have a stronger one, and a dialog might have the largest. To keep things consistent, define these levels once, as CSS variables, and reuse them throughout your project. A small transition on hover can make a button or a card feel responsive.
Inset shadows
The inset keyword changes the shadow from one that's cast outward to one that appears inside the element's frame. Inset shadows are often used to make an input field look recessed or a button look pressed. Experiment with small offsets and a modest blur, as a strong inset shadow can quickly look heavy.
Box shadow or drop shadow?
A box shadow follows the rectangular frame of an element, including its rounded corners. The CSS filter function drop-shadow() follows the visible shape of the content instead, which makes it useful for transparent images such as icons and logos. Use box-shadow for cards, buttons and panels, and drop-shadow for images with irregular outlines.
Performance and accessibility
Very large blurs on many elements can slow down older devices, particularly while they're animating. Keep shadows reasonably small on lists with many items. Don't rely on a shadow alone to show that a button is focused or active. Users with low vision may not be able to see it, so include a visible outline or another clear change as well.
Browser support and syntax
The box-shadow property works in all modern browsers, and you no longer need vendor prefixes. The order of the values matters: the two offsets come first, followed by the blur and then the spread. The color and the inset keyword can appear at the start or the end. If only two lengths are given, they're read as the offsets, and a third length is read as the blur.
Layering several shadows
Many polished designs stack two or three subtle shadows on one element, such as a tight, dark one close to the edge and a wide, faint one farther away. The tool creates one layer at a time, so generate each layer and join them with commas in your stylesheet.
Common mistakes
- Using a hard black shadow. Lower the opacity for a softer look.
- Mixing light directions. Keep your offsets consistent.
- Forgetting the units. Non-zero lengths need a unit such as px.
Related web tools
Compare stylesheets with the diff checker, format your markup with the HTML formatter, and test how a page may appear with the screen resolution checker.
What next
Use this often? Add CSS Box Shad to your Home screen.
Frequently asked questions
How does the CSS box shadow generator work?
You move the sliders, and it updates a live preview and writes the matching box-shadow code.
What is the blur radius?
It controls how soft the shadow's edge is. A larger value makes it bigger and lighter.
What does inset do?
It places the shadow inside the box, rather than outside.
Can a box have more than one shadow?
Yes. In CSS, you can separate several shadows with commas.
Do I need to sign up?
No. It's free and runs in your browser.
Sources
Was this tool helpful?
What went wrong?
We only receive the reason you pick, never what you typed into the tool.
Thanks for your feedback.