How to Use CSS Box-Shadow: Shadow Code
Last updated: · 2 min read
A shadow shows how far an element rises from the surface; trying values by hand is slow. The tool adjusts offset, blur, spread, colour and opacity with sliders, layers several shadows and gives the code. This guide explains the formula, works through an example and lists the usual mistakes.
Formula
box-shadow: [inset] x y blur spread rgba(colour, opacity)
Negative spread shrinks the shadow; several shadows are separated by commas and the first is on top.
What the inputs mean
- Horizontal and vertical
- Offset of the shadow.
- Blur
- Softness of the edge.
- Spread
- Size of the shadow.
- Colour and opacity
- Usually dark at 10–30%.
Worked example: A soft card shadow
- Vertical 10, blur 30, spread −6.
- Dark navy at 35% opacity.
- Code: box-shadow: 0px 10px 30px -6px rgba(15, 23, 42, 0.35).
Result: The card looks slightly raised.
How to read the result
Two layers look more natural than one. In dark mode use a border instead.
Common mistakes
- Pure black shadows look harsh.
- Giving every element the same height.
- Huge blur that costs performance.
Frequently asked questions
What does inset do?
It draws the shadow inside the box.
How is drop-shadow different?
filter: drop-shadow follows the shape of transparent images.
Does it block clicks?
No, it takes no space.
The result is not exact or binding and is for information only; it is not an official document and cannot be used in official procedures. Confirm it with the competent authority or a professional before acting; no liability is accepted for losses arising from its use.