Skip to main content
CalcChef

CSS Box Shadow Generator

Build a CSS box-shadow with up to 5 layers: offset, blur, spread, color, opacity and inset. Copy CSS, Tailwind, SCSS, CSS-in-JS or a variable. How it works

Use the CSS Box Shadow Generator

Shadow Layers (1/5)

Layer 1
Horizontal Offset
10px
Vertical Offset
10px
Blur Radius
20px
Spread Radius
0px

Keyboard Shortcuts

↑↓←→±1px
Shift+Arrow±10px
Apply the shadow to
CSS
box-shadow: 10px 10px 20px 0px rgba(0, 0, 0, 0.25);

About the CSS Box Shadow Generator

A CSS box-shadow is written offset-x offset-y blur spread color, for example box-shadow: 10px 10px 20px 0px rgba(0, 0, 0, 0.25);, which is the shadow the generator starts with. Stack up to five comma-separated layers, make any of them inset, and copy the result as CSS, a Tailwind shadow-[...] class, SCSS, CSS-in-JS or a CSS variable. The shadow can go on the element itself or on its ::before or ::after pseudo-element, and the code then adds the content: "" a pseudo-element needs before it is drawn, position: absolute, inset: 0 and border-radius: inherit to lay it over the box, and position: relative on the element.

How to use this tool

  1. Move the sliders or type values for horizontal offset, vertical offset, blur, spread, color and opacity. The arrow keys change a number by 1 px, or 10 px with Shift.
  2. Click Add Layer for a second shadow, or tick Inset to draw a layer inside the box. The first layer is drawn on top.
  3. Under Apply the shadow to, keep element or pick ::before or ::after. A pseudo-element target writes .element { position: relative; } and .element::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: ...; } in CSS, and relative after:content-[''] after:absolute after:inset-0 after:rounded-[inherit] after:shadow-[...] in Tailwind.
  4. Pick CSS, Tailwind, SCSS, CSS-in-JS or Variable and copy the code.

Frequently asked questions

What order are the values in a CSS box-shadow?
Horizontal offset, vertical offset, blur radius, spread radius, then color, with an optional inset keyword. Only the two offsets are required. A negative horizontal offset moves the shadow left and a negative vertical offset moves it up.
What is the difference between blur and spread?
Blur softens the shadow’s edge: 0 is a sharp edge and larger values spread it out. Spread makes the shadow bigger when positive and smaller when negative, before the blur is applied.
Can a box-shadow have a negative blur?
No, CSS does not allow it. The generator keeps blur between 0 and 100 px, offsets between -100 and 100 px, spread between -50 and 50 px and opacity between 0 and 1, whether you type, click or use the arrow keys.
How do I add more than one box-shadow?
Separate the shadows with commas in one box-shadow value. The first one listed is on top. The generator supports up to five layers and writes them in that order.
How do I use this shadow in Tailwind CSS?
Pick Tailwind in the output tabs and copy the shadow-[...] class, which uses underscores in place of spaces. The Tailwind MD and Tailwind LG presets load the values of the shadow-md and shadow-lg utilities: 0 4px 6px -1px and 0 2px 4px -2px for md, 0 10px 15px -3px and 0 4px 6px -4px for lg, at 10% black.
Does a box-shadow change the size of the element?
No. A box-shadow is painted outside the box without changing its size or pushing other content aside, so a large shadow can overlap neighbors unless you add margin.

Related Tools

View all tools