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.

Shadows are listed top first: the first one is drawn on top of the others.

px

Negative moves the shadow left.

px

Negative moves the shadow up.

px

0 or more: a negative blur is invalid CSS.

px

Positive grows the shadow, negative shrinks it.

HEX, 3 or 6 digits

%
px

The shadow takes the same rounded corners.

box-shadow value

0 4px 12px rgba(0, 0, 0, 0.15)

1 shadow

Preview

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 layers, top first
ShadowxyBlurSpreadColorOpacityInset
104px12px0#00000015%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?

Our own example shadows (not a standard), each computed by this generator
NameUsebox-shadow valueTailwind class
Hairline edgea border drawn as a shadow0 0 0 1px rgba(15, 23, 42, 0.12)shadow-[0_0_0_1px_rgba(15,23,42,0.12)]
Lowcards resting on the page0 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)]
Mediummenus and dropdowns0 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)]
Highdialogs over the page0 12px 32px -8px rgba(15, 23, 42, 0.25)shadow-[0_12px_32px_-8px_rgba(15,23,42,0.25)]
Inseta pressed input fieldinset 0 2px 4px rgba(15, 23, 42, 0.1)shadow-[inset_0_2px_4px_rgba(15,23,42,0.1)]
Focus ringa keyboard focus outline0 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

  1. 1
    Choose how many shadowsPick one, two or three. Two layers, a tight one and a soft one, usually look more natural than one.
  2. 2
    Set 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.
  3. 3
    Check the previewSet the border radius and the preview's box and background colors to match where the shadow will be used.
  4. 4
    Copy 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?
Because the spec defines the blur as 0 or more and says negative values are invalid. A browser discards a declaration with an invalid value, so the whole box-shadow line is ignored and the element keeps whatever shadow it had before. Use 0 for a hard edge.
How do I put more than one shadow on an element?
List them in one box-shadow declaration, separated by commas, such as box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 8px 24px rgba(0, 0, 0, 0.12). The first shadow is drawn on top and each later one behind it.
What is the difference between blur and spread in box-shadow?
Spread changes the shadow's size: positive values expand it in all directions and negative values contract it. Blur softens the edge; the spec describes it as a Gaussian blur with a standard deviation of half the blur radius. With 0 blur the edge is sharp, so a shadow with no offset, no blur and some spread draws a solid outline around the box.
How do I write a box-shadow as a Tailwind class?
Use an arbitrary value: shadow-[…] with the CSS value inside the brackets and each space written as an underscore, as in shadow-[0_4px_12px_rgba(0,0,0,0.15)]. Tailwind turns the underscores back into spaces when it builds the CSS.
Does box-shadow follow border-radius?
Yes. When an element has a border-radius, its box shadow takes on the same rounded corners, and with a spread the shadow's corner radii grow (or shrink, for inner shadows) so it keeps the box's shape.

Sources

Related tools

See all 73 free tools

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