Coderspace Log In

CSS Box Shadow Generator

Build a shadow with sliders, stack layers on top of each other and watch the result in a live preview. Copy the finished box-shadow line or its Tailwind equivalent with one click. Everything is computed in your browser and no value is ever sent to a server.

Shadow settings

Presets

Preview and code

Backdrop
Preview box
Size
Corner radius
Fill colour

Veri Analitiği

What box-shadow does

box-shadow paints a shadow behind or inside an element's box. The shadow follows the element's own border-radius, so a rounded card gets a rounded shadow without any extra work. Shadows take up no space in the document flow, which means adding one never nudges the elements around it.

In interface work a shadow is not decoration, it is a depth cue. It is usually the shadow that tells someone a dropdown, a modal or a dragged card is floating above the rest of the page. A soft, wide shadow reads as high above the surface, while a tight, dark one reads as barely lifted off it.

The four length values

A single shadow layer takes up to four lengths, always in this order:

The third and fourth values are optional. Write only two lengths and the browser reads them as offset-x and offset-y with blur and spread at zero. Leave the colour out and the shadow falls back to currentColor, which is rarely what anyone wants, so state the colour explicitly.

Spread is not blur

Both appear to make a shadow bigger, but they work differently. blur leaves the shape alone and turns its edge into a gradient: fully opaque in the middle, fading to nothing at the rim. spread changes the geometry itself, growing the shadow shape outward by the amount you give it in every direction.

That difference pays off twice. A negative spread pulls the sides of the shadow back under the element so it pools only below, which is how most modern card shadows are built. A zero blur with a positive spread fakes a border instead, letting you add a visual frame without touching layout measurements.

inset shadows

Put the inset keyword at the front of a layer and the shadow is drawn inside the box rather than around it. That is how you get a pressed button, a recessed search field or the soft darkening at the top of a long scrolling list. An inset shadow sits above the background but below the content, so it never dims the text inside the box.

Why designers stack several shadows

One shadow rarely looks like a real object under real light. In the physical world there is a small, dark contact shadow right under an object and a wide, faint ambient shadow spreading out from it. CSS lets you reproduce that by listing several comma separated layers on the same property:

Order matters. The first layer in the list is painted on top of the ones after it, so putting the tightest and darkest layer first keeps it from being swallowed by the wider ones. Material Design's elevation scale is defined exactly this way, as a set of three stacked layers.

A common misstep is reaching for transparent pure black. Over a coloured background a black shadow drains the scene toward grey and looks muddy. Pick a dark, saturated version of the background hue instead. Keeping the CSS gradient generator open in a second tab makes it easier to sample a hue that belongs to the same palette.

box-shadow vs drop-shadow vs text-shadow

Property What it shadows Reach for it when
box-shadow The element's rectangular box, border-radius included Cards, buttons, modals, dropdowns, anything box shaped
filter: drop-shadow() The visible silhouette, skipping transparent pixels PNG and SVG icons, clipped or irregular shapes
text-shadow The outline of the glyphs only Keeping headings readable over imagery, subtle emboss effects

The practical difference is easy to see: give a transparent icon a box-shadow and you get the shadow of its bounding box, not of the icon. drop-shadow reads the alpha channel and traces the real silhouette. In exchange it is harder to stack than box-shadow and generally more expensive to render.

Performance notes

Shadows are resolved during paint. As the blur radius grows, both the painted area and the cost of computing it climb quickly, so a 100px blur repeated across a grid of cards will visibly slow scrolling on mid range phones.

The real trap is animating box-shadow. Every frame forces a repaint, and that work cannot be handed to the GPU. The standard fix is to attach an ::after pseudo element carrying the target shadow, start it at opacity: 0 and animate only the opacity on hover. Opacity animates on the compositor, so no repaint is needed.

Accessibility

A shadow is a decorative signal and should never carry meaning on its own. Communicating focus with a soft glow alone disappears in forced colours mode and for anyone with low vision. If you build a focus ring out of box-shadow, give it enough contrast and at least 2px of thickness, and do not strip outline entirely. Remember that Windows high contrast mode does not paint shadows at all.

Common mistakes

How do you create a CSS box shadow?

  1. 1

    Start from a preset

    The Material elevation levels, the soft card, neumorphism, glow and hard edge presets each replace the whole layer stack in one click. Rather than starting from nothing, pick the one closest to what you want and work from there.

  2. 2

    Tune the layer with the sliders

    The X and Y offsets decide where the light comes from, while blur and spread decide how soft the shadow is. The opacity slider next to the colour picker writes the value out as rgba, and the inset checkbox moves the shadow inside the box.

  3. 3

    Stack a second layer on top

    For convincing depth, put a wide, transparent layer under a tight, dark contact shadow. Use the add layer button to stack them and the arrows to reorder; the layer listed first is painted on top.

  4. 4

    Preview it, then copy the code

    Change the box size, its corner radius, its fill colour and the backdrop to judge the shadow in a real context. Copy the result as a box-shadow line or in Tailwind's shadow-[...] form with one click.

FAQ

The order is offset-x, offset-y, blur, spread, colour. The last two lengths are optional and default to zero. The inset keyword can sit at either end of the layer, though putting it first reads more clearly.

Yes. You list the layers on a single box-shadow declaration, separated by commas. The first layer in the list is painted on top. Writing two separate declarations does not stack them, the second simply overrides the first.

Blur leaves the shape untouched and only softens its edge into a fade. Spread changes the geometry, growing or shrinking the shadow itself. A negative spread is the most practical way to pull a shadow back under the element.

Inset paints the shadow inside the box instead of around it, which reads as a recessed surface. Pressed buttons, sunken search fields and the soft darkening at the top edge of a scrollable list are all built this way.

Shadows are resolved during paint, so every frame forces a repaint and the work cannot be offloaded to the GPU. Put the shadow on an ::after pseudo element and animate its opacity instead, since opacity is handled by the compositor without repainting.

box-shadow follows the element's rectangular box, while drop-shadow reads the alpha channel and traces the visible silhouette. Use drop-shadow for transparent PNG or SVG icons; for box shaped things like cards and buttons box-shadow is both cheaper and easier to layer.

The tool also outputs the value as a Tailwind arbitrary class in the shadow-[...] form, with spaces converted to underscores. If the same shadow appears in several places, it is cleaner to register it as a named entry under boxShadow in your tailwind.config file.

Coderspace is always with you in your tech career!

Learn, code, compete, get hired!

Sign up now