ToolsHub4u

Build a box-shadow and copy the CSS

Adjust the offset, blur, spread, colour and opacity, choose inset if you need it, and copy a box-shadow declaration that matches the preview. No prefix or account needed.

  • Live preview
  • Copy-ready CSS
  • Runs locally
Ready Developer & Utility
1Enter
2Adjust
3Copy result

Box Shadow Generator

1

Shadow settings

px
px
px
px
%

Only affects the preview, not the CSS.

No data yet Live
2

CSS

Shadow with 12px × 18px offset and 40px blur.

Live preview

CSS

  • Blur is appliedA larger blur spreads the shadow edge and makes it softer.
  • Spread is within the blur radiusSpread grows or shrinks the shadow before blurring it.
  • One shadow layerThis generator writes a single shadow. For layered shadows, repeat the declaration separated by commas.
Offset X
12px
Offset Y
18px
Blur
40px
Spread
0px
Alpha
0.18
Inset
No

The preview uses a white card on the chosen surface. The CSS declaration is the part to copy; the surface colour is not included.

This page builds a CSS box-shadow from five values and a colour. Move the sliders for horizontal and vertical offset, blur and spread, set an opacity, choose the shadow colour and tick inset if you need the shadow inside the box. The preview updates as you change a control, and the CSS panel holds a complete rule you can copy or download.

The output is one declaration in a class called .shadow. Rename the class or lift the box-shadow line into your own rule; nothing else is generated, and no vendor prefixes are added because every current browser supports the unprefixed property.

The five values and what they do

The order is fixed: horizontal offset, vertical offset, blur radius, spread radius and colour. Positive offsets move the shadow right and down; negative offsets move it left and up. A blur of zero gives a hard edge, while a larger blur softens the edge over that distance. Spread grows the shadow before it is blurred, so a positive spread makes it larger than the box and a negative spread shrinks it.

The sliders here allow −60 to 60 pixels on each offset, 0 to 120 on blur and −40 to 60 on spread. Those ranges cover ordinary interface shadows. A value outside them is possible in CSS but is easier to write by hand than to reach with a slider.

Blur and spread are not the same control even though both make a shadow look bigger. Blur fades the edge; spread moves the edge outward while keeping it solid. A large spread with a small blur produces a heavy rim, which is why the checklist warns when the absolute spread is larger than the blur.

Colour, opacity and alpha

The colour field accepts a six-digit hex value such as #1c1b18. The separate opacity slider is applied as the alpha channel of an rgba() colour, so 18% becomes rgba(28, 27, 24, 0.18). The stats show the alpha to two decimal places, while the CSS prints the shortest form: 50% appears as 0.5, not 0.50.

An invalid colour does not raise an error. The field is checked against a six-digit hex pattern, and anything else silently falls back to #1c1b18. If the CSS suddenly looks dark grey, check the colour field first; a named colour such as rebeccapurple or a three-digit value such as #333 is not accepted here even though CSS itself would accept it.

The preview surface is a separate colour field. It changes the background behind the sample card so a light shadow is visible, and it is deliberately left out of the CSS. Copying the declaration will not carry the surface with it.

A worked example

The default settings produced the declaration below. The offset is 12 pixels across and 18 down, the blur is 40 pixels, the spread is zero and the colour is the default ink at 18% opacity.

Two shadow settings and the CSS they produced
SettingValuesCSS
Default12, 18, 40, 0, #1c1b18, 18%box-shadow: 12px 18px 40px 0px rgba(28, 27, 24, 0.18);
Inset−10, −8, 0, 20, #ff0000, 50%box-shadow: inset -10px -8px 0px 20px rgba(255, 0, 0, 0.5);

The second run is a hard inner shadow: no blur, a 20-pixel spread and an inset flag. It looks like a thick red edge inside the card. The checklist correctly warned that the spread was larger than the blur, which is the setting most likely to produce a heavy band rather than a soft shadow.

A third run typed red into the colour field at full opacity. The page kept working and wrote rgba(28, 27, 24, 1), because the invalid value fell back to the default. That is useful to know before you spend time wondering why the preview did not change.

Opacity 100 is not a hex colourAt full opacity the output is still rgba(28, 27, 24, 1), not #1c1b18. Both are valid CSS; the generator simply always writes the alpha channel.

Inset shadows and layering

inset moves the shadow inside the element. The offsets then behave as if the light were inside the box: a positive vertical offset puts the shadow at the top edge, which is why inner shadows often use a negative value. Inset shadows are common for pressed buttons, input wells and cards with a cut-out look.

The generator writes one layer. Real interfaces often stack two or three: a tight dark shadow for contact and a wide soft one for depth. To do that, copy the declaration and repeat it after a comma, for example box-shadow: 0 1px 2px rgba(0,0,0,.12), 0 12px 32px rgba(0,0,0,.08);. Each layer is painted in order, with the first on top.

Shadows do not affect layout. They are painted outside the border box and can overlap neighbouring elements, so a large blur may be clipped by an ancestor with overflow: hidden. Check the component in its real container, not only on the preview card.

Copying the result

The CSS panel contains a complete rule, so you can paste it into a stylesheet and rename the selector, or copy only the declaration. The copy button copies the whole rule; the download button saves it as box-shadow.css. Neither action sends anything to a server.

For a quick comparison of two shadows, keep the page open in two tabs and paste each result into your own preview. The CSS beautifier is useful if the declaration ends up inside a minified stylesheet, and the gradient generator covers the background behind the card.

Questions

Common questions

Short answers about this tool and its limits.

What order do box-shadow values go in?

Horizontal offset, vertical offset, blur radius, spread radius and colour, with inset first if used. The generator always writes that order, including the spread even when it is zero.

Why is my shadow not showing?

Check the colour and opacity first, then the offsets. A shadow with zero offset, zero blur and zero spread sits exactly behind the box. An ancestor with overflow: hidden can also clip a large shadow.

What does a negative spread do?

It shrinks the shadow before blurring, so the shadow becomes smaller than the element. Combined with a positive offset it can create a shadow that appears only on one side. The slider allows values down to −40 pixels.

Can I add more than one shadow?

Not in this generator. It writes one layer. Copy the declaration and add further layers after commas in your stylesheet; the first layer is painted on top of the later ones.

Why did my colour change by itself?

The field only accepts a six-digit hex value. A named colour, a three-digit hex or a malformed value falls back to #1c1b18 without an error message. Use the colour picker or type the full six digits.

Does opacity 50 produce 0.50 or 0.5?

The CSS prints 0.5. The stats panel rounds to two decimal places and shows 0.50. Both describe the same alpha value, so the difference is only display formatting.

Do I need -webkit-box-shadow?

No for current browsers. The unprefixed property is supported across Chrome, Firefox, Safari and Edge. A prefix would only matter for very old browser versions that are no longer supported.

Is the shadow saved with my project?

No. The CSS exists only in the page until you copy it or download box-shadow.css. There is no account or history, so save the rule in your stylesheet before closing the tab.