CSS Box Shadow Generator
Set offset, blur, spread, color, opacity and inset with sliders, preview the shadow on a card and copy a box-shadow rule that uses an 8-digit hex color.
The interactive tool loads here when JavaScript runs.
About this toolWhat is the Box Shadow Generator?
The Box Shadow Generator builds a single CSS box-shadow from sliders: Horizontal Offset and Vertical Offset from -100 to 100px, Blur Radius from 0 to 100px, Spread Radius from -50 to 50px, and Opacity from 0 to 100%. Pick a Shadow Color, toggle Inset Shadow, and a white card in the preview shows the result.
The color and opacity are merged into one 8-digit hex value, so the default settings produce box-shadow: 10px 10px 20px 0px #0000004d; where 4d is 30% alpha. You can copy the rule or download box-shadow.css with a .box-shadow class.
It generates one shadow layer. Layered shadows, which most design systems use for elevation, are written by joining several of these with commas. Everything runs in your browser.
- Sliders for x and y offset, blur, spread and opacity
- Inset toggle for inner shadows
- Color and opacity combined into one 8-digit hex value
- Copy the rule or download box-shadow.css
- Runs in your browser with no account
Updated
How to use the Box Shadow Generator
- Drag Horizontal Offset and Vertical Offset to move the shadow. Positive values push it right and down.
- Adjust Blur Radius for softness and Spread Radius to grow or shrink the shadow shape.
- Choose a Shadow Color with the swatch or type a hex value, then set Opacity.
- Switch on Inset Shadow for an inner shadow.
- Click Copy CSS, or Download to save box-shadow.css. The reset button returns to 10px 10px 20px 0px at 30% black.
Worked examples
The default drop shadow
Input
X 10, Y 10, blur 20, spread 0, #000000 at 30%
Output
box-shadow: 10px 10px 20px 0px #0000004d;
Opacity 0.3 times 255 is 76.5, which rounds to 77 or 4d in hex. That is appended to the color as the alpha channel.
A subtle inner well
Input
X 0, Y 2, blur 4, spread 0, #000000 at 20%, Inset on
Output
box-shadow: inset 0px 2px 4px 0px #00000033;
inset is written first and the shadow is drawn inside the box, darkest along the top edge. This is the classic look for a text input or a pressed toggle.
Shadow on one side only
Input
X 0, Y 12, blur 12, spread -8, #000000 at 40%
Output
box-shadow: 0px 12px 12px -8px #00000066;
The negative spread shrinks the shadow so it no longer shows along the left and right edges, leaving a shadow only under the bottom edge.
Background and insight
box-shadow takes up to four lengths and a color. The first two are the x and y offsets, the third is the blur radius and the fourth is the spread. Positive spread grows the shadow shape before blurring; negative spread shrinks it, which is how you get a shadow that only peeks out from one side. The inset keyword flips the shadow inside the border box, so it reads as a pressed or recessed surface.
Blur is not a hard edge plus fuzz. The CSS Backgrounds and Borders spec defines it so that the shadow edge is blurred by an approximation of a Gaussian with a standard deviation of half the blur radius. In practice, a 20px blur spreads visible shadow about 20px beyond the offset shape, which is worth remembering when shadows get clipped by an ancestor with overflow: hidden.
The 8-digit hex form #rrggbbaa comes from CSS Color Module Level 4 and is supported by all current browsers. It is the same as rgba(0, 0, 0, 0.3) for the default. If you maintain styles for very old browsers, convert it to rgba. Shadows are also not free to paint: large blur radii on many elements, or animating box-shadow itself, can cost frames on low-end phones. Animate the opacity of a pseudo-element that carries the shadow instead.
Common use cases
Card and modal elevation
Tune the offset and blur until a card lifts off the page by the amount your design calls for.
Pressed and focused states
Generate an inset shadow for active buttons or a recessed input field.
Matching a mockup
Translate the drop shadow values from a design file into the exact CSS developers need.
Prototyping elevation tokens
Try a range of shadows and copy each one into a set of design tokens such as shadow-sm, shadow-md and shadow-lg.
Tips and limitations
- Design tools often call spread "size" and express offsets as distance plus angle. Convert to x and y before comparing values.
- Shorthand hex like #000 is expanded to #000000 before the alpha is added. Any other text falls back to black, and the tool shows a warning.
- For realistic elevation, stack two shadows: a tight, darker one for contact and a large, faint one for ambient light, separated by a comma.
- Shadows are clipped by ancestors with overflow: hidden. Add padding or move the shadow to an inner element if the edge gets cut off.
- box-shadow follows border-radius but ignores transparency in images. For PNG cut-outs, use filter: drop-shadow() instead.
Sources and further reading
- CSS Backgrounds and Borders Module Level 3, W3C. The box-shadow definition, including spread, inset and the Gaussian blur rule
- CSS Color Module Level 4, W3C. Defines the 8-digit #rrggbbaa hex notation
- box-shadow CSS property, MDN Web Docs. Syntax, multiple shadows and examples
Frequently asked questions
What does spread radius do in box-shadow?
Spread grows or shrinks the shadow shape before it is blurred. A positive spread makes the shadow larger than the element in every direction; a negative spread makes it smaller. Negative spread combined with a y offset is the usual way to get a shadow that only appears below an element.
What does #0000004d mean in the generated shadow?
It is an 8-digit hex color: the first six digits are the color (black) and the last two are the alpha channel. 4d is 77 out of 255, about 30% opacity. It is equivalent to rgba(0, 0, 0, 0.3) and works in all current browsers.
How do I add more than one shadow to an element?
Separate the shadows with commas in a single box-shadow declaration, for example box-shadow: 0px 1px 2px #0000001a, 0px 8px 24px #00000026;. The first shadow in the list is drawn on top. Generate each layer here and join them by hand.
Why is my box-shadow cut off at the edges?
A parent element with overflow: hidden, overflow: auto or a clip-path clips anything painted outside it, and shadows count. Give the parent enough padding to contain the blur, or apply the overflow rule to a different wrapper.
Should I use box-shadow or filter drop-shadow?
Use box-shadow for rectangular or rounded boxes; it follows border-radius and supports spread and inset. Use filter: drop-shadow() when the shape comes from transparency, such as a PNG icon or an SVG, because it follows the visible pixels. drop-shadow has no spread or inset.
Is animating box-shadow bad for performance?
It can be on slower devices, because changing a shadow forces the browser to repaint it every frame. A common pattern is to put the larger shadow on a pseudo-element and animate its opacity, which the compositor can handle without repainting.
Is there an in-depth guide to the Box Shadow Generator?
Yes. “CSS Gradients, Box Shadows and Transforms: The Parts People Get Wrong” covers the background, how it works, common pitfalls and worked examples. Read the full guide.
Related Tools You May Like
Free, in-browser tools that pair well with this one.