CSS Box Shadow Generator
Generate CSS box-shadow values visually. Adjust horizontal offset, vertical offset, blur radius, spread radius, opacity, and color with sliders. Live preview, inset mode, and one-click copy. Runs in your browser.
- Runs in your browser
- Tool input is not uploaded to ZeroTool servers
- Free · No Sign-Up
Scan with WeChat to share this tool
Examples, details and FAQ Worked examples, how it compares with other tools, and answers to common questions.
box-shadow Syntax Reference
/* offset-x offset-y [blur] [spread] [color] [inset], in any order of color and inset */
box-shadow: 4px 4px; /* blur 0, spread 0, color currentColor */
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12); /* spread omitted = 0 */
box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
box-shadow: 0 1px 2px rgba(0,0,0,.2), 0 8px 24px rgba(0,0,0,.12); /* first = on top */
Per CSS Backgrounds and Borders Level 3, a shadow takes two to four lengths. Omitted lengths are 0, a negative blur radius is invalid (the whole declaration is dropped), and an omitted color is currentColor. The tool always writes all four lengths and an explicit color, so its output does not depend on the element's text color.
Example: the Default Shadow
On load the sliders sit at 5, 5, 10, 0 and opacity 30% with black, and the output is:
box-shadow: 5px 5px 10px 0px rgba(0, 0, 0, 0.30);
The blur radius does not set the width of the soft edge directly. The spec asks for a Gaussian blur with a standard deviation of half the blur radius, so a 10px blur produces a transition about 20px wide, centered on the shadow's edge. That is why a large blur makes the shadow look bigger than the box even with spread at 0.
Example: Card Elevation and a Focus Ring
Set horizontal offset 0, vertical offset 4, blur 16, spread 0, opacity 12% for a soft card shadow:
box-shadow: 0px 4px 16px 0px rgba(0, 0, 0, 0.12);
For a focus ring, set every slider to 0 except spread 3, type #1a73e8 into the color field and set opacity to 50%:
box-shadow: 0px 0px 0px 3px rgba(26, 115, 232, 0.50);
With zero offset and zero blur, the shadow is a solid 3px band that follows the element's border-radius; the spec grows the corner radii by the spread distance so a pill-shaped button keeps a pill-shaped ring. Turn on Inset and the same values draw the band just inside the border instead, which does not change the element's footprint.
Limits
- One shadow per output. Layered shadows (a tight dark one plus a wide faint one) have to be combined by hand with commas.
- Slider ranges: offsets and spread −50 to 50px, blur 0 to 100px, opacity in whole percent. Values outside these ranges, and units other than
px, need a manual edit. - Hex input:
#with 6 digits sets the color; 8 digits also set the opacity from the last two digits, rounded to a whole percent, so#0000001f(31/255) becomes 12%. 3-digit codes, color names andrgba()keep the previous color and show a hint. - Forced colors. In Windows High Contrast and other forced-colors modes,
box-shadowcomputes tonone(CSS Color Adjust Level 1 §3.1). A focus ring drawn only with a shadow disappears there; keep anoutline(for exampleoutline: 2px solid transparent, which forced-colors mode repaints in the system color) alongside it. - Shadows are clipped under the box. An outer shadow is drawn only outside the border edge, so it never shows through a semi-transparent background. For a shadow that follows the shape of a transparent PNG or text, write
filter: drop-shadow(4px 4px 8px rgba(0, 0, 0, 0.3))by hand; the CSS filter generator covers the other nine filter functions.
Common Use Cases
- Hard drop shadow:
box-shadow: 4px 4px 0 rgba(0,0,0,1)— retro / bold design style - Inner shadow (input field):
box-shadow: inset 0 2px 4px rgba(0,0,0,0.1) - Glow effect:
box-shadow: 0 0 20px rgba(99,102,241,0.6)— neon or glow highlight
CSS Variables Integration
You can store your shadow values in CSS custom properties for consistent reuse across a design system:
:root {
--shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.12);
--shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
--shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.15);
--shadow-focus: 0 0 0 3px rgba(59, 130, 246, 0.45);
}
.card { box-shadow: var(--shadow-md); }
.card:focus-visible { outline: 2px solid transparent; box-shadow: var(--shadow-focus); }
Related Tools
- CSS Variables Generator — store your shadow values as design tokens
- CSS Grid Generator — build grid layouts visually
FAQ
What is the CSS box-shadow property?
The CSS box-shadow property adds one or more shadow effects to an element. Each shadow is defined by horizontal offset, vertical offset, an optional blur radius, an optional spread radius, and an optional color (currentColor when omitted). Adding the inset keyword draws the shadow inside the element's padding box.
What does each slider control?
Horizontal Offset moves the shadow left (negative) or right (positive). Vertical Offset moves it up (negative) or down (positive). Blur Radius controls how blurry the shadow edge is — 0 means a sharp edge. Spread Radius expands or shrinks the shadow size. Opacity controls the shadow's transparency from 0% (invisible) to 100% (fully opaque).
What is inset shadow?
The inset keyword makes the shadow appear inside the element instead of outside. It gives the effect of a depressed or recessed surface, commonly used for input fields or pressed buttons.
What color format does the tool output?
rgba() with the opacity slider written as a two-decimal alpha value, for example rgba(0, 0, 0, 0.30). The color comes from the color picker or a # code typed into the text field: 6 hex digits set the color, and 8 digits also move the opacity slider to the last two digits rounded to a whole percent (#00000080 gives 50%).
Can I use multiple box shadows?
Yes — CSS supports multiple shadows separated by commas, and the first one in the list is painted on top. The tool edits one shadow at a time, so build each layer separately and join the values with commas yourself.
Are my shadow values sent or saved anywhere?
No. The CSS is built in your browser tab; the slider, color and inset values are not sent to a server and are not saved in browser storage. The page's analytics records usage events with the tool name and the action (generate or copy), not the shadow values.