Free tool · Developer tools
Box shadow generator
Move the sliders and watch the shadow change on the preview box. Add layers, switch a layer to inset, then copy the finished box-shadow CSS.
- Free
- No sign-up
- Runs in your browser
- 1 layer
- Includes inset
- Above
- 12 px
- Right
- 22 px
- Below
- 32 px
- Left
- 22 px
Offsets move the shadow, blur softens it and spread grows or shrinks it. The first layer is drawn on top. A shadow does not change the size or position of the box, so leave this much space around it.
How to use the Box Shadow Generator
- Move Horizontal offset, Vertical offset, Blur radius, Spread radius and Opacity, or type a number in the box beside each slider.
- Pick the Shadow colour. Tick Inset to put the shadow inside the box.
- Press Add layer for another shadow, and choose which one to edit under Layer to edit. Remove layer deletes the current one. Start from an example loads a ready-made look.
- Press Copy CSS and paste the declaration into your stylesheet.
How do I make a box shadow in CSS, and what do the values mean?
A shadow is written box-shadow: offset-x offset-y blur spread color;. The first two lengths move the shadow: a positive horizontal offset moves it right and a positive vertical offset moves it down. The third is the blur radius, which softens the edge and cannot be negative. The fourth is the spread radius: a positive value makes the shadow larger than the box and a negative value makes it smaller. The colour is written here as rgba(), so the opacity slider becomes the last number. This page starts with 0 10px 30px -8px rgba(15, 33, 56, 0.3), a soft shadow that falls below the box.
A larger blur makes the shadow bigger and lighter. If you leave out the colour in your own CSS, the shadow takes the text colour (the CSS color property), so it is easier to control when you set it. A shadow does not change the size of the box or push other elements around, and it follows the box's rounded corners. Use the corner setting under Preview only to see how your shadow looks on a rounded box; it is not part of the copied CSS.
Under the CSS, the page lists the room the shadow needs on each side. It is about blur plus spread, moved by the offset. For the default, that is 12 px above, 22 px on both sides and 32 px below. Leave at least that much space around the box, or neighbouring elements and the edge of the page will cut the shadow off.
How do I add multiple shadows or an inset shadow?
Separate shadows with commas in one declaration. Press Add layer, select it under Layer to edit and set its values. The first layer in the list is drawn on top of the ones after it, so put a small, sharp shadow first and a large, soft one after. With several layers the CSS is written one layer per line, which is easier to read and edit.
Tick Inset to turn a layer into an inner shadow. The box then looks pressed in, because the shadow is drawn inside the box, above its background and below its content. Inset layers do not add to the room the shadow needs outside the box. You can mix both: an outer drop shadow and an inset highlight on the same box.
Several faint layers often look more natural than one dark shadow. The Layered and smooth example uses five layers whose offset and blur double each time, from 0 1px 1px up to 0 16px 16px, each at 8% opacity. Ring (spread only) uses a spread of 4 px with no blur, which draws a solid outline that follows the corners.
How do I get a soft, natural-looking shadow?
Use a larger blur, a low opacity and a small downward offset, and add a negative spread so the shadow does not stick out wider than the box. That is what the default does: a 30 px blur, a vertical offset of 10 px, a spread of -8 px and 30% opacity. Tinting the shadow with a dark shade of the page colour instead of pure black often looks calmer. A hard shadow is the opposite: no blur and a larger offset, as in the Hard offset example.
Keep in mind that a soft shadow is a weak cue. Do not rely on it alone to show where a card, field or button ends, because people with low vision or a washed-out screen may not see it. A border or enough colour contrast makes the edge clear. Pick colours and opacity by eye on the real background: the background and box colours under Preview only let you test a dark page or a flat colour.
Use it with
- Px to Rem Converter: convert px, rem, em.
- Cron Expression Generator: build and explain cron schedules.
- Base64 Encoder Decoder: encode or decode Base64.
Questions
What do the four box-shadow values mean?
Horizontal offset, vertical offset, blur radius and spread radius, followed by a colour. The offsets move the shadow, blur softens it, and spread makes it larger (positive) or smaller (negative).
How do I add more than one box shadow?
Separate the shadows with commas in the same box-shadow declaration. The first one is drawn on top. In this tool, press Add layer and edit each layer in turn.
How do I make an inset shadow?
Put the keyword inset at the start of the shadow. It draws the shadow inside the box so the box looks pressed in. Tick Inset on a layer to add it.
Can the blur radius be negative?
No. Negative blur values are not allowed in CSS, so the blur slider starts at 0. The spread radius can be negative.
Does box-shadow change the layout?
No. A shadow does not change the size of the box or move other elements, and it follows the box's border-radius. Leave enough space around the box so the shadow is not cut off.
Is the CSS sent anywhere?
No. The preview and the CSS are made in your browser, and nothing you set is uploaded.
Sources
- MDN Web Docs: box-shadow, read
How this page was made: the tool's results are computed in your browser by the code on this page, using the sources listed above; the explanations were drafted with AI help and checked against the tool's own output.