CSS Shadow Generator

Build layered CSS `box-shadow` and `text-shadow` with real-time sliders and presets for Material Design, neon glow, and more.

Preview
Shadow layers (lower layers are drawn on top)
Select Shadow value Order Delete
Edit selected layer
Presets

Shadows look completely different depending on the background color. Adjust the background color above to match the one you'll actually use. On a white background, a light black with 8-15% opacity looks natural, while darker values are better for dark backgrounds.

What is the CSS Shadow Generator?

The CSS `box-shadow` property adds depth to your designs, but guessing the right values for offset, blur, spread, and color can be a cycle of trial and error. This generator makes it visual: just move the sliders and see the shadow change instantly on a preview element. The real power comes from stacking multiple shadow layers, which is the secret to creating realistic, subtle depth. You can add, duplicate, and reorder layers to get the perfect effect. Switch to `text-shadow` mode to create drop shadows or striking neon effects for text. It's free, no signup required.

How to use

  1. Select `⬛ box-shadow` or `🅰 text-shadow` mode at the top.
  2. In the 'Shadow layers' table, choose a layer to edit. Adjust its properties using the sliders for offset, blur, spread, color, and opacity.
  3. Click `+ Add layer` or `⧉ Duplicate` to stack multiple shadows for a more natural effect. Reorder them using the ↑ and ↓ buttons.
  4. Set the `Background` color to match your site's design, then click `Copy` to get the generated CSS.

CSS Shadow Generator guide

How this tool is used in real work, and what to watch out for.

Why Single-Layer Shadows Look Fake

In the real world, an object doesn't cast a single type of shadow. A sharp, narrow shadow forms where the object touches a surface, while a softer, more diffuse shadow appears farther away. This is because light sources have area, they aren't single points.

Using just one `box-shadow` value can only express one of these characteristics. That's why no matter how much you adjust the blur, the result often looks stamped on. The solution is to stack multiple shadow layers with different properties.

LayerRoleValue Characteristics
Layer 1 (Closest)Gives the sense that the element is touching the ground.Small y (1-2px), small blur, 5-8% opacity
Layer 2 (Middle)Creates the actual sense of depth.Medium y (4-8px), medium blur, 8-10% opacity
Layer 3 (Farthest)Creates an ambient, floating feeling.Large y (12-24px), large blur, negative spread, 10-14% opacity
The "Layered Soft" preset uses this exact configuration. Click it, then try deleting the layers one by one to see what each one does. The Material Design "Elevation" presets are also all composed of three layers.

Opacity Should Be Much Lower Than You Think

The most common reason beginner-made shadows look awkward is their intensity. Using 30-50% black doesn't look like a shadow; it looks like a black smudge. On a white background, a natural shadow is usually around 8-15% black. That's why this tool's default is 12%.

Another tip: if you use pure black (`#000000`) for the shadow color, the resulting gray tones can make the screen look muddy. Using a dark color from the background's family (e.g., a navy-tinged `#0f172a`) looks much more sophisticated. This is why UI design systems rarely use pure black for shadows.

  • Card shadows: 8-14% opacity, large blur, and a spread of 0 or a negative value.
  • A negative spread makes the shadow smaller than the element, creating a subtle effect just beneath it. This looks much more refined.
  • Always use a positive `y` value. Light comes from above. A shadow with a negative `y` feels wrong.
  • `x` should generally be 0. A horizontally shifted shadow is only used in special cases to simulate side lighting.
Always match the preview's background color to the background you'll actually be using. The same shadow will look completely different on a white background (#ffffff) versus a light gray one (#f8fafc). A value tweaked for a white background will look like it's almost disappeared on a gray one.

Fixing Disappearing Shadows in Dark Mode

A black shadow on a black background is invisible. It sounds obvious, but if you take a shadow painstakingly crafted for light mode and use it as-is in dark mode, your cards will blend into the background, completely losing all sense of depth. Even cranking the opacity up to 40% won't help—a darker black on top of black is still just black.

For dark mode, you need to change your entire approach to creating depth. Here are three methods that real-world dark UIs use.

  • Brighten the surface: The more an element "floats," the lighter its background becomes compared to the page background. This is the official method for Material's dark theme. It uses brightness, not shadow, to express elevation.
  • Use a border ring: Like the "Border Ring" preset, setting only `spread` to 1-2px and keeping x, y, and blur at 0 creates a thin outline that defines the element's edge. Use a light color with low opacity.
  • Add a top highlight: An `inset` shadow with a light color at the top of an element can simulate a lit top edge.
css
/* Light Mode — depth via shadow */
.card {
  background: #fff;
  box-shadow: 0 1px 2px rgba(15,23,42,.06),
              0 4px 8px -2px rgba(15,23,42,.08),
              0 12px 24px -6px rgba(15,23,42,.10);
}

/* Dark Mode — depth via brightness + thin ring */
@media (prefers-color-scheme: dark) {
  .card {
    background: #1e293b;              /* Lighter than background (#0f172a) */
    box-shadow: 0 0 0 1px rgba(255,255,255,.06),
                0 12px 24px -6px rgba(0,0,0,.5);
  }
}
You can test dark mode shadows directly by changing the preview background color to a dark value. The neon presets also only look right on a dark background.

Performance: Shadows Aren't Free

A `box-shadow` with a large `blur` is an expensive effect that the browser has to recalculate on every repaint. You might not notice it normally, but it becomes a problem in two situations.

  • A list with dozens of shadowed cards: This will cause choppy scrolling, especially on low-end devices.
  • A `transition` on `box-shadow` for a hover effect: The shadow value is recalculated on every frame of the animation. It's much smoother to pre-render the shadow and transition its opacity, as shown below.
css
/* Slow — recalculates shadow every frame */
.card { transition: box-shadow .2s; }
.card:hover { box-shadow: 0 20px 40px -12px rgba(30,41,59,.22); }

/* Fast — pre-render shadow and transition opacity */
.card { position: relative; }
.card::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  box-shadow: 0 20px 40px -12px rgba(30,41,59,.22);
  opacity: 0; transition: opacity .2s;
  pointer-events: none;
}
.card:hover::after { opacity: 1; }
While you can stack up to 8 layers, you'll rarely need more than 3 in practice. Unless you're creating a special effect like neon or a text outline, 3 layers are sufficient, and any more will just degrade performance.

text-shadow Has Different Rules

When you switch the mode to `text-shadow`, the `spread` and `inset` controls disappear. That's because the `text-shadow` property doesn't support them. It only accepts four values: x-offset, y-offset, blur, and color.

The most practical use for text shadow isn't for styling, but for ensuring text is readable on top of an image. Adding a very subtle black shadow (around 30-40% opacity, 4px blur) to white text makes it legible whether the background is light or dark.

  • The "Text Outline" preset works by placing four `blur: 0` shadows in four directions. It's a robust solution for complex backgrounds but can make the text look thicker. `-webkit-text-stroke` is an alternative.
  • The "Text 3D" preset builds thickness by stacking multiple shadows offset by 1px each. The trick is to make each successive layer progressively darker.
  • Avoid using shadows on body text. On small fonts, a shadow can blur the letterforms and actually make the text harder to read. As a rule, only use it on large headings.
When using multiple layers, the order is important. Layers at the top of the table are drawn in front on the screen. Try changing the order with the buttons (↑ ↓) to see the effect. For 3D effects, changing the layer order can completely alter the result.

Frequently asked questions

What's the difference between 'Blur radius' and 'Spread radius'?

`Blur radius` softens the shadow's edges. `Spread radius` grows (positive value) or shrinks (negative value) the shadow's overall size before it is blurred.

Why should I use multiple shadow layers?

Real-world shadows aren't uniform. Stacking a small, dark shadow with a larger, fainter one creates more realistic depth than a single layer can. The Material Design 'Elevation' presets use this technique with three layers each.

What does the 'Inset shadow' option do?

The `Inset shadow` option draws the shadow inside the element's border instead of outside. This is useful for creating effects like pressed buttons or depressed panels. This option is only available for `box-shadow`.

How do I create a neon glow effect?

Click one of the 'Neon' presets. The effect is made by stacking multiple shadows of the same color with different blur radiuses and zero offset. For the best result, change the `Background` color to something dark.