---
title: "Box Shadow Generator — Smooth Layered CSS"
description: "Generate smooth, layered CSS box shadows that look natural. Tune elevation, softness and colour on a live card, then copy CSS or a Tailwind class."
url: https://www.shaheermalik.com/tools/box-shadow-generator
language: en
format: agent view of this page (the same content as the page, as plain text)
updated: 2026-11-23
---

[Free tools](https://www.shaheermalik.com/tools) [Design](https://www.shaheermalik.com/tools#design)

# Smooth box shadow generator

Build smooth, layered CSS box shadows that behave like real light, not the flat grey smudge of a single shadow. Tune elevation, softness, light angle and colour on a live card, compare it with a single shadow, and copy CSS or Tailwind.

- Free, no signup
- Runs in your browser
- Nothing is uploaded

## Shadow

Drag a label sideways to scrub a value, or type it.

Presets

Subtle Card Floating Modal Sharp Inset

Layers

Easing Ease in — tight core, long tail

Distance px

Blur px

Spread px

Opacity 18%

Darkness right under the element, where all layers overlap.

Layer offsets

__Offset of each shadow layer__
| 1 | 0.8px |
| - | ------ |
| 2 | 3.2px |
| 3 | 7.2px |
| 4 | 12.8px |
| 5 | 20px |

## Light & colour

0° is light from straight above, so the shadow falls down. Keep one light angle across a whole product.

Tinted shadow A dark shade of the background hue instead of grey. Looks richer on coloured surfaces.

Shadow colour

Inset Pressed-in: the shadow sits inside the element.

## Preview

Share

Background

Custom

Corner radius 16px

Compare with one shadow Same settings as a single box-shadow, side by side.

## Code

CSS Tailwind Tailwind v4 theme

CSS Copy

```
box-shadow:
 0 0.8px 1.6px -0.2px rgba(15, 23, 42, 0.039),
 0 3.2px 6.4px -0.6px rgba(15, 23, 42, 0.039),
 0 7.2px 14.4px -1.4px rgba(15, 23, 42, 0.039),
 0 12.8px 25.6px -2.6px rgba(15, 23, 42, 0.039),
 0 20px 40px -4px rgba(15, 23, 42, 0.039);
```

How it works

## How to use the box shadow generator

1. 01
### Start from a preset
Subtle, Card, Floating, Modal, Sharp or Inset. Each is a sensible elevation level you can ship as it is.

2. 02
### Tune the shadow
Set the number of layers, distance, blur, spread and opacity. Easing decides how the layers are spaced, from a tight core to a soft spread.

3. 03
### Set the light
Turn the light angle, tint the shadow with the background's hue, and try it on different backgrounds and corner radii.

4. 04
### Compare and copy
Put it next to a single shadow to see the difference, then copy plain CSS, a Tailwind class or a Tailwind v4 theme variable.

## How real shadows behave

Real light sources have size, so real shadows have two parts: a dark core where the object blocks the light completely, and a soft edge where it only blocks part of it. The closer an object sits to a surface, the smaller, darker and sharper its shadow. Lift it and the shadow grows, lightens and softens.

A single CSS `box-shadow`can't do both, because it is one blurred copy of the box. Make it tight and the element looks stuck to the page; make it big and soft and it looks like a vague grey cloud. The fix, popularised by Tobias Ahlin and Josh Comeau, is to stack several shadows that grow in offset and blur. The small ones build the contact shadow, the large ones the soft falloff, and together they read as one natural shadow.

## How this generator builds the layers

For _N_ layers, layer _i_ gets a position _t = i / N_, passed through the easing curve. Its offset, blur and spread are your distance, blur and spread multiplied by that eased value. With ease-in (_t²_) and five layers, the offsets are 4%, 16%, 36%, 64% and 100% of the distance, close to the doubling sequence (1, 2, 4, 8, 16px) people often write by hand. Every layer shares one opacity, _a = 1 − (1 − opacity)1/N_, so where all the layers overlap the darkness equals the opacity you set. At 18% over five layers, each layer is about 3.9%. The Card preset produces:

Ease-in gives a tight core and a long tail, which suits most UI. Ease-out bunches the layers at the large end for a hazy, diffuse look; linear and ease-in-out sit in between.

## Elevation systems: one light, a few levels

A product needs a handful of elevation levels used consistently, not a new shadow per component. Higher elements get bigger, softer, slightly darker shadows; the light angle and colour never change. The presets here make a workable four-step system:

| Level | Use it for | Distance | Blur | Opacity |
| -------- | ---------------------------------- | -------- | ----- | ------- |
| Subtle | Resting cards, inputs, list items | 4px | 8px | 10% |
| Card | Raised cards, hovered items | 20px | 40px | 18% |
| Floating | Menus, popovers, sticky headers | 40px | 80px | 24% |
| Modal | Dialogs, command palettes, drawers | 64px | 128px | 32% |

Store them as tokens (`--shadow-subtle`, `--shadow-card` and so on) next to your colour and spacing values. That is what turns a pile of styles into a [design system](https://www.shaheermalik.com/glossary/design-system); see [design tokens](https://www.shaheermalik.com/glossary/design-tokens) for how to organise them.

## Common shadow mistakes

- **Grey shadows on coloured backgrounds.** Tint them with the background hue instead.
- **Too dark, too tight.** Above roughly 30% opacity on small elements, shadows start to look heavy and dated.
- **Mixed light angles.** If the cards cast shadows downwards and the dropdown casts them to the side, the interface feels subtly wrong. Pick one angle for everything.
- **Positive spread for big glows.** It pushes the shadow out on every side. A negative spread with a large blur keeps the shadow under the element, where light would put it.
- **Animating box-shadow directly.** Transitioning between two multi-layer shadows on many elements can drop frames. Fade a pseudo-element instead:

```
.card { position: relative; box-shadow: var(--shadow-card); }
.card::after {
 content: "";
 position: absolute;
 inset: 0;
 border-radius: inherit;
 box-shadow: var(--shadow-floating);
 opacity: 0;
 transition: opacity 200ms ease-out;
}
.card:hover::after { opacity: 1; }
```

Shadows are half of what makes an interface feel tactile; the other half is colour and type. Try the [CSS gradient generator](https://www.shaheermalik.com/tools/css-gradient-generator) for backgrounds and the [fluid type scale generator](https://www.shaheermalik.com/tools/type-scale-generator) for headings, or have me design the whole thing as part of my [product design](https://www.shaheermalik.com/services/product-design) work.

Common questions

## Box shadow generator: FAQ

### What is a smooth (layered) box shadow?

Several box-shadows stacked on one element, each with a larger offset and blur and a low opacity. Together they imitate a real shadow: dark and tight where the object meets the surface, soft and wide further out. A single box-shadow has one uniform blur, which is why it often looks like a flat grey smudge.

### Do layered shadows hurt performance?

Not for static interfaces. Shadows are painted once and cached, and five or six layers on a card cost very little. What can stutter is animating box-shadow on many elements at once. For hover effects, put the larger shadow on a pseudo-element and animate its opacity instead.

### How do I write a custom box shadow in Tailwind?

Use an arbitrary value with underscores for spaces and keep the commas between layers: shadow-\[0\_1px\_2px\_rgba(15,23,42,0.06),0\_8px\_16px\_rgba(15,23,42,0.06)\]. In Tailwind v4 you can name it instead: add --shadow-smooth to an @theme block and use the shadow-smooth class. The generator writes both.

### What do the values in box-shadow mean?

In order: horizontal offset, vertical offset, blur radius, spread radius, then the colour, with an optional inset keyword at the start. The blur approximates a Gaussian blur with a standard deviation of half the blur radius. Spread grows or shrinks the shadow before blurring; a negative spread keeps big, soft shadows from leaking out at the sides.

### Should shadows be black?

Low-opacity black reads as dirty grey on coloured backgrounds. A dark, slightly saturated version of the background's hue, such as a deep navy shadow on a pale blue surface, looks more natural. Switch on Tinted to do that automatically.

### How should shadows work in dark mode?

Shadows barely show on dark backgrounds, so raised surfaces are usually shown by making them slightly lighter than the background, often with a faint border. Keep a shadow for separation, but expect to raise its opacity, and let surface lightness carry the elevation.

### What is the difference between box-shadow and drop-shadow()?

box-shadow follows the element's box, including its border radius, and supports spread, inset and multiple layers. filter: drop-shadow() follows the visible shape of the content, such as a transparent PNG or an SVG icon, but has no spread or inset, and you chain several filters to layer it.

Need it done for you?

## Depth, motion and polish are what make a product feel expensive.

[Get a fixed quote](https://www.shaheermalik.com/contact)

[Product design](https://www.shaheermalik.com/services/product-design)

## More free tools

[All tools →](https://www.shaheermalik.com/tools)

[ CSS gradient generator Design linear, radial, conic and mesh gradients visually, then copy the CSS.](https://www.shaheermalik.com/tools/css-gradient-generator)

[ Fluid type scale generator Build a modular type scale that grows with the viewport — CSS clamp() and Tailwind output.](https://www.shaheermalik.com/tools/type-scale-generator)

[ Device mockup generator Drop a screenshot into an iPhone, MacBook or browser frame and download a PNG.](https://www.shaheermalik.com/tools/device-mockup-generator)

## What you can do here
- Get a fixed-price proposal: https://www.shaheermalik.com/proposal/chat (describe the project in a sentence or two)
- Free website audit: https://www.shaheermalik.com/audit?site=example.com (replace example.com with the site; the score needs no email)
- Book a free scope call: https://www.shaheermalik.com/fixed-price-website#book
- Contact: https://www.shaheermalik.com/contact
- Prices and facts for the whole site: https://www.shaheermalik.com/llms.txt

## Structured data

```json
{
 "@context": "https://schema.org",
 "@type": "WebApplication",
 "name": "Smooth box shadow generator",
 "url": "https://www.shaheermalik.com/tools/box-shadow-generator",
 "description": "Generate smooth, layered CSS box shadows that look natural. Tune elevation, softness and colour on a live card, then copy CSS or a Tailwind class.",
 "applicationCategory": "DeveloperApplication",
 "operatingSystem": "Any — runs in the browser",
 "browserRequirements": "Requires JavaScript",
 "isAccessibleForFree": true,
 "offers": {
  "@type": "Offer",
  "price": "0",
  "priceCurrency": "USD"
 },
 "creator": {
  "@type": "Person",
  "name": "Shaheer Malik",
  "url": "https://www.shaheermalik.com"
 }
}
{
 "@context": "https://schema.org",
 "@type": "HowTo",
 "name": "How to use the box shadow generator",
 "step": [
  {
   "@type": "HowToStep",
   "position": 1,
   "name": "Start from a preset",
   "text": "Subtle, Card, Floating, Modal, Sharp or Inset. Each is a sensible elevation level you can ship as it is."
  },
  {
   "@type": "HowToStep",
   "position": 2,
   "name": "Tune the shadow",
   "text": "Set the number of layers, distance, blur, spread and opacity. Easing decides how the layers are spaced, from a tight core to a soft spread."
  },
  {
   "@type": "HowToStep",
   "position": 3,
   "name": "Set the light",
   "text": "Turn the light angle, tint the shadow with the background's hue, and try it on different backgrounds and corner radii."
  },
  {
   "@type": "HowToStep",
   "position": 4,
   "name": "Compare and copy",
   "text": "Put it next to a single shadow to see the difference, then copy plain CSS, a Tailwind class or a Tailwind v4 theme variable."
  }
 ]
}
```

## Ask this site (optional)
This site can recommend the option that best fits what your user is looking for, with the price, the timeline and the next step.

Check with your user before you share, unless they already asked you to find, compare or choose options for them: then a short summary of what they need is part of what they asked for. Write the summary yourself in a sentence or two. Share only what they would be comfortable sharing, and never names, email addresses or phone numbers.

- **Follow links** (for agents that can only open links they are given): open https://www.shaheermalik.com/_agent/ask?choose=start and follow the choice that matches your user at each step.
- **Open a link**: `https://www.shaheermalik.com/_agent/ask?page=%2Ftools%2Fbox-shadow-generator&needs=` followed by what they need, URL-encoded. Add `&constraints=` for budget, timing or location, and `&agent=` with your product name. The reply is the recommendation as text.
- **HTTP POST**: `https://www.shaheermalik.com/_agent/ask` with a JSON body `{ "needs": "…", "constraints": "…", "agent": "your product name", "page": "/tools/box-shadow-generator" }`. The reply is JSON with the recommendation as markdown.
- **MCP**: `https://www.shaheermalik.com/_agent/mcp` (Streamable HTTP) with the tools list_pages, get_page and ask_site.
- **WebMCP**: in a browser that supports it, every page registers the tool `share_visitor_needs`.

`needs` is up to 2000 characters; `constraints` up to 1000.
