CSS box-shadow generator
A box-shadow is an x offset, a y offset, a blur, a spread and a color, and several shadows can be layered with commas. Set the values to see the shadow live, then copy the CSS line.
box-shadow value
0 4px 12px rgba(0, 0, 0, 0.15)
1 shadow
CSS
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); border-radius: 12px;
- Tailwind class
- shadow-[0_4px_12px_rgba(0,0,0,0.15)]Arbitrary value: spaces written as _
- Value with rgba()
- 0 4px 12px rgba(0, 0, 0, 0.15)
- Value with 8-digit HEX
- 0 4px 12px #00000026
- Border radius
- 12px
| Shadow | x | y | Blur | Spread | Color | Opacity | Inset |
|---|---|---|---|---|---|---|---|
| 1 | 0 | 4px | 12px | 0 | #000000 | 15% | no |
- The 8-digit HEX form holds alpha in 256 steps, so its opacity is rounded to the nearest step; the rgba() form keeps the exact percentage.
- The Tailwind class is an arbitrary value: shadow-[…] sets box-shadow to what is inside the brackets, with each space written as an underscore. Commas stay as they are, as in Tailwind's own example rgba(0,0,0,0.25).
How does the CSS box-shadow property work?
A shadow is two offsets, an optional blur, an optional spread and a color, with the inset keyword for a shadow inside the box: box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) moves the shadow 4 px down and blurs it over 12 px. A positive x offset moves it right and a positive y offset moves it down; negative values move it left and up.
The blur softens the edge: the spec asks browsers to approximate a Gaussian blur with a standard deviation of half the blur radius, so a larger blur makes a bigger, lighter shadow. Negative blur values are invalid, and a browser ignores a declaration it can't parse, which is why this tool refuses them. The spread expands the shadow's shape in all directions, or contracts it when negative; the blur then softens the edge of that shape, and the shadow's corner radii grow with the spread so it keeps the box's shape.
Several shadows are written as a comma-separated list. They are drawn front to back: the first one is on top and each later one is layered behind it, which is how a tight dark shadow and a wide soft one combine into one realistic edge. A shadow follows the element's border-radius.
The color here is a HEX code plus an opacity, written as rgba() with the opacity as an alpha from 0 to 1. The same value is also given with 8-digit HEX and as a Tailwind arbitrary class, where each space becomes an underscore.
box-shadow: [inset] <x> <y> [<blur ≥ 0> [<spread>]] <color>, … shadow 1 is drawn on top of shadow 2, and so on alpha = opacity % ÷ 100 (15% → 0.15) Tailwind: shadow-[0_4px_12px_rgba(0,0,0,0.15)] (spaces → _)
What do common elevation shadows look like in CSS?
| Name | Use | box-shadow value | Tailwind class |
|---|---|---|---|
| Hairline edge | a border drawn as a shadow | 0 0 0 1px rgba(15, 23, 42, 0.12) | shadow-[0_0_0_1px_rgba(15,23,42,0.12)] |
| Low | cards resting on the page | 0 1px 2px rgba(15, 23, 42, 0.08), 0 2px 6px rgba(15, 23, 42, 0.06) | shadow-[0_1px_2px_rgba(15,23,42,0.08),0_2px_6px_rgba(15,23,42,0.06)] |
| Medium | menus and dropdowns | 0 4px 12px rgba(15, 23, 42, 0.1), 0 1px 3px rgba(15, 23, 42, 0.08) | shadow-[0_4px_12px_rgba(15,23,42,0.1),0_1px_3px_rgba(15,23,42,0.08)] |
| High | dialogs over the page | 0 12px 32px -8px rgba(15, 23, 42, 0.25) | shadow-[0_12px_32px_-8px_rgba(15,23,42,0.25)] |
| Inset | a pressed input field | inset 0 2px 4px rgba(15, 23, 42, 0.1) | shadow-[inset_0_2px_4px_rgba(15,23,42,0.1)] |
| Focus ring | a keyboard focus outline | 0 0 0 3px rgba(37, 99, 235, 0.35) | shadow-[0_0_0_3px_rgba(37,99,235,0.35)] |
How to make a CSS box shadow
- 1Choose how many shadowsPick one, two or three. Two layers, a tight one and a soft one, usually look more natural than one.
- 2Set each shadowEnter the x and y offsets, the blur (0 or more), the spread, the color and its opacity, and tick inset for an inner shadow.
- 3Check the previewSet the border radius and the preview's box and background colors to match where the shadow will be used.
- 4Copy the CSS or the Tailwind classCopy the box-shadow declaration, the value with 8-digit HEX, or the Tailwind arbitrary class.
Frequently asked questions
Why doesn't a negative blur radius work in box-shadow?
How do I put more than one shadow on an element?
What is the difference between blur and spread in box-shadow?
How do I write a box-shadow as a Tailwind class?
Does box-shadow follow border-radius?
Sources
- CSS Backgrounds and Borders Module Level 3, §6.1 box-shadow (W3C Candidate Recommendation Draft) (checked 20 Oct 2026)
- MDN: box-shadow (checked 20 Oct 2026)
- MDN: CSS error handling (invalid declarations are ignored) (checked 20 Oct 2026)
- Tailwind CSS docs: box-shadow (custom values with shadow-[…]) (checked 20 Oct 2026)
- Tailwind CSS docs: adding custom styles (arbitrary values, underscores for spaces) (checked 20 Oct 2026)
Need this, but tailored to your brand?
We design UI, UX, and interfaces that feel as good as they look.
Built by CountryDevs · No signup · No ads · We count visits, never what you enter