CSS box shadow generator
Pick a preset or set the offset, blur, spread, color and opacity with the sliders. Stack several shadows and turn any of them into an inner shadow (inset). The preview updates instantly and the finished CSS is one click away. You can also paste your own CSS below and keep editing it.
How it is calculated
How box-shadow works
According to the W3C specification (CSS Backgrounds and Borders Level 3), a shadow consists of two to four lengths, an optional color and the optional keyword inset:
| Value | Meaning |
|---|---|
| 1st length | Horizontal offset to the right (negative: to the left) |
| 2nd length | Vertical offset downward (negative: upward) |
| 3rd length | Blur radius, never negative; 0 if omitted |
| 4th length | Spread: grows the shadow, a negative value shrinks it |
| Color | if omitted, the text color is used (currentColor) |
inset | draws the shadow inside the box instead of outside |
Separate multiple shadows with commas. The first shadow is painted on top, the others behind it. Shadows do not affect layout or create scrollbars – but a parent with overflow: hidden will clip them.
How far does the blur reach?
The spec requires a blur that approximates a Gaussian blur with a standard deviation of half the blur radius. The resulting transition is about twice as wide as the blur value and centered on the shadow edge – so it reaches roughly one blur radius outward.
Example 0 10px 25px -5px: the edge sits 25 − 5 = 20 px outside the box, shifted 10 px down. The shadow therefore extends about 20 − 10 = 10 px at the top, 20 px on each side and 20 + 10 = 30 px at the bottom. The generator shows these values under “How far the shadow extends” – handy as padding so nothing gets clipped.
Common uses
- Cards and buttons: combine two shadows – a small, darker one for definition and a large, soft one for depth.
- Focus ring:
0 0 0 3pxin an accent color draws an outline that does not shift the layout. - Inner shadow:
insetmakes input fields look recessed.
Frequently asked questions
What is the difference between blur and spread?
Blur (3rd value) softens the edge without changing the base area of the shadow. Spread (4th value) grows or shrinks the shadow area itself before it is blurred. A blur of 0 with a positive spread gives a hard outline.
How do I stack multiple shadows?
Separate them with commas, e.g. 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24). The first shadow is drawn on top. In the generator, add more layers with “+ Shadow”.
Why is my shadow cut off?
Shadows do not count toward an element’s size. If a parent has overflow: hidden or overflow: auto, anything sticking out is clipped. Give the parent as much padding as the generator shows under the shadow’s extent.
Does box-shadow work in every browser?
Yes. box-shadow, including multiple shadows, inset and rgba() colors, is supported unprefixed by all current browsers. The generator writes transparent colors as rgba(), which older browsers understand as well.
Sources and legal basis
- css-backgrounds-3, § 6.1: W3C – CSS Backgrounds and Borders Module Level 3: the box-shadow property
- css-backgrounds-3, § 6.1.2: W3C – CSS Backgrounds and Borders Module Level 3: Blurring Shadow Edges
- MDN Web Docs – box-shadow
As of:
Related tools
- CSS border radius generatorRound corners with sliders: all corners linked or each on its own, px or %, elliptical 8-value syntax – shortest CSS shorthand, live preview and copy button.
- CSS gradient generatorBuild CSS gradients: linear, radial or conic, as many color stops as you need, angle and fallback color – live preview and CSS ready to copy.
- Color converter: HEX, RGB, HSL, HSV, CMYKConvert color codes: HEX to RGB, RGB to HEX, HSL, HSV, HWB and CMYK – type any format or use the color picker and copy the result, right in your browser.
- Color contrast checker (WCAG 2.2)Check the contrast between text and background colors: WCAG 2.2 contrast ratio with AA/AAA ratings for normal text, large text and UI components.
- Aspect Ratio CalculatorCalculate the aspect ratio from width and height (1920 × 1080 = 16:9), find the missing side, decimal value, nearest standard ratio and CSS aspect-ratio.
- Base64 Encode and DecodeEncode and decode Base64 and Base64url with proper UTF-8, plus URL encode/decode (percent-encoding). Clear error messages, runs locally in your browser.