# Box Shadow Generator

> The Box Shadow Generator creates CSS box-shadow code with one or more layers, each with its own offset, blur, spread, colour, opacity and inset setting, and copies it as CSS or a Tailwind arbitrary class.

URL: https://atechcraft.com/box-shadow-generator/
Category: Image Tools
Last updated: 2026-12-01
Author: Abdul Moid Khan, ATechCraft

Runs in your browser. Your data never leaves your device.

## How to use the Box Shadow Generator

1. Adjust X and Y offset, blur, spread, colour and opacity.
2. Add more layers for softer, more realistic shadows.
3. Tick inset for an inner shadow.
4. Copy the CSS or the Tailwind class.

## What is a box shadow generator?

A box shadow generator creates the CSS `box-shadow` code that gives cards, buttons and pop-ups a sense of depth. This one lets you stack several shadow layers, adjust each layer's offset, blur, spread, colour and opacity, switch to an inner (inset) shadow, and preview the result on your own box and background colours. Copy the result as plain CSS or as a Tailwind CSS class.

## How does CSS box-shadow work?

Each shadow layer has up to six parts ([MDN: box-shadow](https://developer.mozilla.org/en-US/docs/Web/CSS/box-shadow)):

```css
box-shadow: [inset] X Y blur spread colour;
```

- **X offset** moves the shadow right (positive) or left (negative).
- **Y offset** moves it down (positive) or up (negative). Light usually comes from above, so most shadows have a positive Y.
- **Blur** softens the edge. 0 gives a hard edge; bigger numbers spread the fade over more pixels.
- **Spread** grows (positive) or shrinks (negative) the shadow before it is blurred.
- **Colour** is usually black or a dark tint of your brand colour, with transparency. This tool writes it as `rgba()`.
- **Inset** draws the shadow inside the box, as if the box were pressed into the page.

Several layers are separated by commas. The first layer is drawn on top.

## Why use layered shadows?

In real life, a shadow is dark and sharp close to the object and lighter and softer further away. One CSS shadow cannot do both. Two or three layers can:

- A **tight layer** (small Y and blur, higher opacity) defines the edge.
- A **wide layer** (larger Y and blur, low opacity, often negative spread) creates the soft fall-off.

That is why the tool starts with two layers instead of one.

## Worked example

The default settings give:

```css
box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.12), 0px 8px 24px -4px rgba(0, 0, 0, 0.18);
```

Read it as two shadows. The first is 1 pixel down with a 2-pixel blur at 12% black: a crisp edge. The second is 8 pixels down, blurred over 24 pixels and pulled in by 4 pixels so it does not peek out the sides, at 18% black: a soft lift.

For a "pressed" button, add a layer with **inset** ticked, Y = 2, blur = 4, opacity 0.2.

| Effect | Suggested settings |
| --- | --- |
| Subtle card | 0 1 3 0 at 10%, plus 0 1 2 −1 at 10% |
| Raised pop-up | 0 10 15 −3 at 10%, plus 0 4 6 −4 at 10% |
| Focus glow | 0 0 0 3 in your brand colour at 40% |
| Pressed button | inset 0 2 4 0 at 20% |

## Tips

1. **Keep opacity low.** Real shadows are rarely darker than 25% black. Heavy shadows look dated.
2. **Tint the shadow** with a dark version of the background colour for a richer look. Find shades with the [Color Palette Generator](https://atechcraft.com/color-palette-generator/).
3. **Use the same light direction** for every shadow on a page so they look consistent.
4. **Combine with a gradient background** from the [CSS Gradient Generator](https://atechcraft.com/css-gradient-generator/), or sample a brand colour using the [Color Picker from Image](https://atechcraft.com/color-picker-from-image/).
5. **Dark mode:** shadows barely show on dark backgrounds. Use lighter surfaces or a subtle border instead.
6. Ship lean CSS with the [Code Minifier](https://atechcraft.com/code-minifier/).

## Limitations

- **Performance:** a few shadows are cheap, but huge blur values on many elements that move or animate can make scrolling choppy on slow phones. Animate `opacity` of a shadowed layer rather than the shadow itself.
- **Shape:** `box-shadow` follows the element's box and border radius. For irregular shapes such as PNG icons, use `filter: drop-shadow()` instead.
- **Tailwind output** uses an arbitrary value class. For a design system, add the shadow to your Tailwind theme instead.
- **Printing:** most browsers do not print shadows by default.

## Key terms

- **Offset:** how far the shadow is moved from the element.
- **Blur radius:** how soft the shadow edge is.
- **Spread radius:** how much bigger or smaller the shadow is than the element.
- **Inset shadow:** a shadow drawn inside the element.

## Frequently asked questions

### Why use more than one shadow layer?

Real shadows are sharper near the object and fade away. Stacking a tight, darker shadow with a wide, faint one looks more natural than a single blurred shadow.

### What is the difference between blur and spread?

Blur softens the edge of the shadow. Spread grows or shrinks the shadow before blurring.

### Do box shadows slow down a page?

Normal shadows are cheap. Very large blurred shadows on elements that animate can cost performance on slow phones.

### How do I use the Tailwind output?

Paste the class, such as shadow-[0px_4px_8px_0px_rgba(0,0,0,0.2)], onto your element. Tailwind generates it automatically.
