Skip to main content
ponderloop

CSS Box Shadow Generator (Multiple Layers, Inset, Tailwind)

A CSS box shadow is a list of layers, each with an X offset, a Y offset, a blur, a spread and a color. The Card preset has 2 layers and is box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 8px 24px -4px rgba(0, 0, 0, 0.16); and the Tailwind class is shadow-[0_1px_3px_rgba(0,0,0,0.12),0_8px_24px_-4px_rgba(0,0,0,0.16)]. Edit the layers, add inset shadows, change the box and background colors, or paste a shadow you already have to edit it, then copy the result.

Updated Runs in your browser: nothing you enter is uploadedHow this tool works

Preview

Build the shadow

Presets

Shadow layers (1 to 8)

Offsets, blur and spread in pixels. Colors as hex, rgb(), hsl(), hwb() or a name such as rebeccapurple. The first layer is on top.

  1. Layer 1
  2. Layer 2

CSS and Tailwind

CSS

box-shadow:
  0 1px 3px rgba(0, 0, 0, 0.12),
  0 8px 24px -4px rgba(0, 0, 0, 0.16);

Tailwind CSS (arbitrary value)

shadow-[0_1px_3px_rgba(0,0,0,0.12),0_8px_24px_-4px_rgba(0,0,0,0.16)]

Paste an existing shadow

Paste a box-shadow value or the whole declaration: layers, rgba() colors, inset and rem lengths are understood.

The presets as CSS and Tailwind

Each row is a preset of the generator above, written by the same function. Presets also set the box and background colors in the preview.
PresetCSS valueTailwind class
Subtle0 1px 2px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.1)shadow-[0_1px_2px_rgba(0,0,0,0.08),0_1px_3px_rgba(0,0,0,0.1)]
Card0 1px 3px rgba(0, 0, 0, 0.12), 0 8px 24px -4px rgba(0, 0, 0, 0.16)shadow-[0_1px_3px_rgba(0,0,0,0.12),0_8px_24px_-4px_rgba(0,0,0,0.16)]
Floating0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 25px 50px -12px rgba(0, 0, 0, 0.25)shadow-[0_10px_15px_-3px_rgba(0,0,0,0.1),0_25px_50px_-12px_rgba(0,0,0,0.25)]
Insetinset 0 2px 4px rgba(0, 0, 0, 0.25), inset 0 0 0 1px rgba(0, 0, 0, 0.08)shadow-[inset_0_2px_4px_rgba(0,0,0,0.25),inset_0_0_0_1px_rgba(0,0,0,0.08)]
Neumorphic9px 9px 16px rgba(163, 177, 198, 0.6), -9px -9px 16px rgba(255, 255, 255, 0.5)shadow-[9px_9px_16px_rgba(163,177,198,0.6),-9px_-9px_16px_rgba(255,255,255,0.5)]

What the paste box understands

Each value is read by the same parser as the paste box and written back by the generator, as one line.
PastedWritten back asNote
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);0 4px 12px rgba(0, 0, 0, 0.2)A whole declaration: the property name and semicolon are dropped.
0 1px 2px rgba(0,0,0,.1), 0 4px 8px hsl(210 50% 40% / 25%)0 1px 2px rgba(0, 0, 0, 0.1), 0 4px 8px rgba(51, 102, 153, 0.25)Two layers: commas inside rgba() and hsl() are not layer breaks.
#0003 inset 0 2px 4pxinset 0 2px 4px rgba(0, 0, 0, 0.2)inset and the color can come before, after or between the lengths.
0 .25rem 1rem red !important0 4px 16px #ff0000rem and em lengths become px (16px per rem); !important is dropped.
2px 2px2px 2px 0 #000000No color: CSS uses the text color, which the tool replaces with black.

The values of a layer

ValueWhat it doesAllowed here
X offsetMoves the shadow right (positive) or left (negative).-1000 to 1000 px
Y offsetMoves the shadow down (positive) or up (negative).-1000 to 1000 px
BlurSoftens the edge: 0 is sharp, larger is softer and wider.0 to 1000 px
SpreadGrows (positive) or shrinks (negative) the shadow before it is blurred.-1000 to 1000 px
Color and opacityThe shadow color. Opacity multiplies with any alpha the color already has.0 to 100 percent
InsetDraws the shadow inside the box edge instead of outside it.On or off

How to make a CSS box shadow

  1. Start from a preset or a single layer. Pick Subtle, Card, Floating, Inset or Neumorphic to load a starting point, or edit the first layer. The preview box shows every change at once.
  2. Set the offset, blur and spread of each layer. Each layer has an X and Y offset, a blur, a spread, a color with an opacity, and an inset switch. The example's first layer is 1px down with 3px blur and 12% black; its second is 8px down, 24px blur, -4px spread and 16% black.
  3. Add, remove and reorder layers. Use Add layer for up to 8 layers, and the Up, Down and Remove buttons on a layer. The first layer is painted on top, so order matters when shadows overlap.
  4. Match your page. Set the box color and the background color to the ones of your design. A shadow that looks right on white can disappear on a dark background.
  5. Copy the CSS or the Tailwind class. Copy the box-shadow declaration, or the shadow-[...] class for your markup. To change a shadow you already have, paste it into the paste box and choose Use this shadow.

Frequently asked questions

What do the numbers in box-shadow mean?
In order they are the X offset, the Y offset, the blur radius and the spread radius, then the color. In the first example layer, 0 1px 3px rgba(0, 0, 0, 0.12) means no sideways shift, a 1px shift down, a 3px blur and no spread. Only the two offsets are required; blur and spread default to 0, and the keyword inset can come first or last.
How do I add more than one shadow?
Separate the layers with commas: 0 1px 3px rgba(0, 0, 0, 0.12), 0 8px 24px -4px rgba(0, 0, 0, 0.16). The first layer is on top. Layering a tight, faint shadow with a wide, softer one looks more natural than one heavy shadow, because real light casts both a contact shadow and a diffuse one. The generator allows up to 8 layers.
What is the difference between blur and spread?
Blur softens the shadow's edge without changing its core size; spread changes the size of the shadow before blurring. A negative spread with a larger Y offset, as in the Card and Floating presets, keeps the shadow narrower than the box so it shows mostly underneath, not around the sides.
What does inset do?
An inset shadow is drawn inside the border of the box, over its background and under its content, so the box looks pressed in instead of raised. The offsets then move the shadow inside: a positive Y offset darkens the top edge.
How do I use the shadow in Tailwind CSS?
Use an arbitrary value: shadow-[...] with the value inside the brackets. Tailwind does not allow spaces in a class name, so each space is written as an underscore, and the spaces after commas are left out. For the example: shadow-[0_1px_3px_rgba(0,0,0,0.12),0_8px_24px_-4px_rgba(0,0,0,0.16)]. Tailwind also has built-in shadow-sm, shadow-md and shadow-lg classes for common cases; the arbitrary form covers custom layers.
Can I paste a box-shadow from another site?
Yes. Paste the value, or the whole declaration, into the paste box. It reads hex, rgb(), rgba(), hsl(), hwb() and named colors, any number of layers up to 8, inset anywhere in a layer, and px, rem and em lengths. It does not read values that depend on the page, such as var(--shadow) or currentColor, and it tells you which layer it could not read.
Why does my shadow look different on a dark background?
A black shadow at low opacity darkens whatever is behind it, so on a dark page it hardly shows. On dark designs use a higher opacity, a larger blur, or a tinted shadow color, and set the preview background to your page color to check it.
What is a neumorphic shadow?
Neumorphism makes a box look molded from its background, using two shadows with opposite offsets on a box that is the same color as the page: a darker one down-right and a lighter one up-left. The Neumorphic preset is 9px 9px 16px rgba(163, 177, 198, 0.6), -9px -9px 16px rgba(255, 255, 255, 0.5). It has low contrast, so do not rely on it alone to show buttons or fields.
Do large shadows slow a page down?
A big blur radius on a large element costs more to paint, and animating box-shadow repaints on every frame. For hover effects it is usually cheaper to fade the opacity of a second element that already has the larger shadow. A few static shadows are not a problem.
Is anything I enter sent anywhere?
No. The values and any shadow you paste are read and the CSS is built in your browser, and nothing you type is stored or sent anywhere.

How it works

Each layer is written as [inset] <x> <y> <blur> [<spread>] <color>, following CSS Backgrounds and Borders Level 3: lengths are numbers of pixels, shown without a unit when they are 0, and the spread is left out when it is 0. The color is read with the same parser as the color converter on this site (hex with 3, 4, 6 or 8 digits, rgb(), hsl(), hwb(), transparent and the 148 CSS color names); its alpha is multiplied by the layer opacity, rounded to three decimals, and written as a hex color when the result is fully opaque and as rgba(r, g, b, a) otherwise. Layers are joined with commas, and the first one is painted on top. The Tailwind class wraps the same value in shadow-[...] with each space written as an underscore and the spaces after commas removed. The paste box removes comments, a leading box-shadow: and a trailing !important or semicolon, splits the layers on commas that are not inside brackets, and splits each layer into tokens the same way. The word inset is accepted anywhere in a layer, a token that starts with a digit, sign or dot is a length (a bare number other than 0 is rejected because CSS requires a unit), and the one other token is the color. Two to four lengths are required in a row, rem and em are converted at 16 pixels, and a layer without a color gets black, because CSS would use the text color. The preview applies the same value to a box on a page of the colors you choose. Everything runs in your browser and nothing you enter is sent anywhere.

Sources

More: Color and CSSAll developer toolsAll toolsHome & DIY calculators