Toolstia / CSS box shadow generator

CSS box shadow generator

A good shadow separates a card from its background without drawing attention to itself. This generator gives you sliders for horizontal and vertical offset, blur, spread, opacity and corner radius, plus color pickers for the shadow, the box and the page, so you can judge the effect in the same colors as your design. The box-shadow line updates as you drag.

Use it to design card elevation, button hover states, floating menus and pressed inputs. The Inset option draws the shadow inside the box. When the preview looks right, copy the one-line CSS and paste it into your rule. The output always lists all four lengths, for example 8px 10px 24px 0px, followed by an rgba color.

How it works

  1. Adjust the offsets, blur, spread and opacity.
  2. Pick the shadow, box and page colours.
  3. Copy the CSS.

The parts of a shadow

The horizontal and vertical offsets move the shadow, the blur softens its edge, and the spread makes it larger or smaller than the box. A negative spread shrinks it, which gives a tight, lifted look.

Soft and natural shadows

Real shadows are soft and faint. Try a small vertical offset, a larger blur and an opacity between 10% and 25%. Heavy black shadows look dated.

Inset shadows

Tick Inset to draw the shadow inside the box, as if the box were pressed in. This works well for input fields and pressed buttons.

The output

The shadow is written with an rgba colour, so the opacity is part of the colour. The same line works in all current browsers.

What each number does

Offsets move the shadow right and down for positive values, left and up for negative ones. Blur softens the edge, and the CSS specification describes it as a Gaussian blur, so a bigger value spreads the fade over a wider band. Spread grows or shrinks the shadow shape before the blur is applied, and the blur slider cannot go below zero.

With the starting values, the tool writes box-shadow: 8px 10px 24px 0px rgba(0, 0, 0, 0.25);. Setting the vertical offset to 4, blur to 6, spread to -1, a slate color and 10 percent opacity gives box-shadow: 0px 4px 6px -1px rgba(15, 23, 42, 0.1); which is a subtle card shadow.

Building a believable elevation scale

Raised surfaces usually use a larger vertical offset and a larger blur as they get higher, with the opacity staying low. A small element might use 0px 1px 3px 0px at around 12 percent, a card 0px 4px 12px 0px at 15 percent, and a modal 0px 12px 32px -8px at 25 percent. These are starting points, not rules, and you should judge each on your own background.

A negative spread with a positive vertical offset keeps the shadow narrower than the box, so it shows mainly underneath. That avoids the halo around the edges that makes cheap shadows obvious.

Inset shadows for fields and buttons

With Inset ticked, the output starts with the word inset, for instance inset 0px 2px 4px 0px rgba(0, 0, 0, 0.2). A small offset downward with a modest blur makes a field look recessed, and a darker inset on a button can show a pressed state when you switch it on in the active style.

An inset shadow is drawn inside the border, above the background and below the content, so it will not cover text or child elements.

Colors, backgrounds and dark themes

The shadow color is converted to red, green and blue values and combined with your opacity in one rgba color. A shadow tinted with the background hue, such as a dark blue on a pale blue page, usually looks more natural than pure black.

Shadows are nearly invisible on dark backgrounds, because black on dark gray has little contrast. For dark themes, rely on lighter surface colors or borders for separation, and test using the page color control here.

Limits and alternatives

This tool creates one shadow with no layering. To stack shadows, copy the line twice and join them with a comma, listing the top shadow first. The corner radius slider only changes the preview box and is not part of the copied CSS, so set the radius in your own rule. Box shadows follow the box shape and its border radius, not the visible shape of an image with transparent areas; for that case, the filter property with drop-shadow is the usual choice.

Questions

Can I add more than one shadow?

Not in this tool. In CSS, separate extra shadows with a comma.

Does it work for text?

No. Text shadows use a different property, text-shadow, with no spread.

Why can I not see the shadow?

The shadow is the same colour as the page, or its opacity is too low. Change the page colour to test.

Is anything uploaded?

No. Your design stays in your browser and is never sent anywhere.

Does a box shadow change the size of my element?

No. Shadows are painted outside the layout box and do not move other elements, but they can be clipped by a parent that hides overflow.

Why is my shadow cut off at the edge?

A container with overflow hidden or a scroll area is clipping it. Add padding to the container or move the overflow setting.

Can I animate the shadow?

Yes, with a CSS transition on box-shadow, as long as both states have the same number of shadows. Large blurs on many moving elements can slow low-end devices.

What is the difference between blur and spread?

Blur controls how soft the edge is. Spread changes how big the solid shadow is before blurring.

Should I use pixels or rem?

The tool outputs pixels. You can convert them by hand if your design scales with font size.