CSS Box Shadow Generator

Generate CSS box-shadow declarations with offsets, blur, spread, opacity, inset shadows, and layered elevation presets.

Last updated: August 2026 | By Workshelve Team

Shadow

.card {
  box-shadow: 0px 18px 40px -12px rgba(15, 23, 42, 0.28);
}
Shadow preview

What box-shadow Controls

CSS box-shadow draws one or more shadows around an element's border box. It is commonly used for cards, menus, modals, buttons, raised panels, and inset pressed states.

Each shadow uses horizontal offset, vertical offset, blur radius, optional spread radius, and color. Offsets and spread may be negative, but blur radius cannot be negative.

This generator is one-way because shadow lists can include multiple comma-separated layers, inset keywords, CSS variables, color functions, and design-token references that do not reverse into a single reliable control set.

How the Shadow CSS Is Built

1. Offsets, blur, spread, and opacity are parsed with parseFloat.
2. X and Y offsets may be negative; blur must be zero or positive.
3. Spread may be negative to pull the shadow inward before blur is applied.
4. Layered mode joins two complete shadows with a comma, preserving paint order.
0px 18px 40px -12px
Soft elevated card shadow
inset 0px 2px 8px 0px
Inner pressed surface
negative spread
Keeps the shadow tighter
two comma-separated shadows
Depth plus contact shadow

Worked Example: Card Elevation

Build a layered card shadow with depth and a closer contact shadow:

Soft
0px 24px 70px -24px rgba(2, 6, 23, 0.28)
Hard
0px 8px 18px -8px rgba(14, 165, 233, 0.24)
Result

The broad layer creates elevation, while the smaller tinted layer gives the component a sharper contact point near its base.

CSS Box Shadow FAQ

Can box-shadow offsets be negative?

Yes. Negative X moves the shadow left, and negative Y moves it upward.

Can blur radius be negative?

No. CSS blur radius must be zero or positive, so the generator rejects negative blur values.

What does negative spread do?

Negative spread shrinks the shadow shape before blur is applied, which helps create tighter modern shadows.

What does inset mean?

Inset draws the shadow inside the element, often used for pressed buttons, recessed controls, or inner depth.

Which shadow layer appears first?

Box-shadow layers are painted front to back, so the first shadow in a comma-separated list is visually on top.

Why use rgba instead of HEX?

Shadow opacity is usually essential. RGBA keeps the chosen HEX color and the alpha value explicit.

Can zero blur be valid?

Yes. Zero blur creates a sharp shadow edge and can be useful for outlines or hard offset effects.

Why is this not bidirectional?

Valid shadow CSS may include many layers, variables, color functions, and omitted values, so reverse parsing would only cover a small subset.

Related Tools