The CSS Box Shadow Generator lets you shape a shadow with sliders and see the result on a preview card before you copy a single line of CSS. Shadows give flat interfaces a sense of depth: a card appears to float above the page, a button looks pressable, and a modal seems to sit in front of everything else. Small changes to offset, blur, and spread can turn a harsh dark edge into a soft, believable lift, and this tool makes those changes visible in real time.
Writing a box-shadow value by hand means remembering the order of five values and guessing numbers until the result looks right. The CSS Box Shadow Generator removes the guessing. Drag the horizontal and vertical offsets, set the blur and spread, pick a colour, choose an opacity, and optionally switch the shadow inward. The preview updates with every movement, and the CSS panel shows the exact declaration, including the colour converted to rgba form with your chosen opacity.
What Is the CSS Box Shadow Generator?
The CSS Box Shadow Generator is a visual editor for the CSS box-shadow property. It builds one shadow from six inputs: a horizontal offset, a vertical offset, a blur radius, a spread radius, a colour, and an opacity percentage. An optional inset checkbox turns the shadow inward, so it appears inside the element instead of outside it. The output is a single box-shadow declaration that you can paste into any rule.
The preview is a white card with a thin border, labelled as a shadow preview, sitting on a neutral shell. The default shadow is offset 8 pixels to the right and 12 pixels down, with a blur of 24 pixels, no spread, a dark colour, and 25 percent opacity. That default is a useful starting point for a card: visible enough to create depth, soft enough not to dominate. From there, every slider moves the shadow in a predictable direction.
Opacity is handled by converting the chosen hex colour to an rgba colour in the output. For example, a dark colour at 25 percent opacity appears as an rgba value with an alpha of 0.25. This matters because a shadow at full opacity usually looks too heavy, while a shadow at low opacity reads as ambient light. The tool keeps the colour picker simple and puts the transparency control where it belongs, in the opacity slider.
- Offset sliders: horizontal offset from minus 50 to 50 pixels, and vertical offset from minus 50 to 50 pixels, so shadows can fall in any direction.
- Blur and spread: blur from 0 to 100 pixels softens the edge, and spread from minus 20 to 50 pixels grows or shrinks the shadow.
- Colour and opacity: a colour picker plus an opacity slider from 0 to 100 percent, combined into an rgba value.
- Inset option: a checkbox that adds the inset keyword, turning the shadow into an inner shadow.
- Live preview: a white preview card that shows the shadow exactly as the CSS describes it.
How to Use the CSS Box Shadow Generator
Work from the default shadow outward. Change one slider at a time and watch the card, so you learn what each value does.
- Set the horizontal offset. Drag the Horizontal offset slider between minus 50 and 50 pixels. Positive values push the shadow to the right, negative values push it to the left, and zero centres it horizontally. Most card shadows use a small positive value or zero.
- Set the vertical offset. Drag the Vertical offset slider between minus 50 and 50 pixels. Positive values drop the shadow below the element, as if light comes from above, and negative values lift it above. A small positive value is the most natural choice for cards and buttons.
- Adjust the blur radius. Drag the Blur radius slider between 0 and 100 pixels. Zero gives a hard edge, and larger values soften the shadow until it fades into the background. Values between 12 and 32 pixels suit most interface shadows.
- Adjust the spread. Drag the Spread slider between minus 20 and 50 pixels. Positive spread enlarges the shadow in all directions, and negative spread shrinks it. Leave it at zero unless you want a noticeably larger or tighter shadow.
- Pick the shadow colour and opacity. Use the Shadow color picker for the base colour, then drag the Opacity slider between 0 and 100 percent. Dark colours at 15 to 35 percent opacity usually look most natural, because real shadows are rarely pure black.
- Choose inset if needed. Tick the Inset shadow checkbox to place the shadow inside the element, which suits pressed buttons and inset input fields. Leave it unticked for the usual floating effect.
- Copy the CSS. Click Copy CSS when the preview looks right. The panel contains one box-shadow declaration. Paste it into the rule for your card, button, or panel.
Key Features of the CSS Box Shadow Generator
The tool covers the full single-shadow syntax in one panel, with ranges wide enough for subtle and dramatic effects alike.
- Bidirectional offsets: negative and positive ranges let the shadow fall above, below, left, or right, which is useful for toolbars, footers, and elements lit from different directions.
- Wide blur range: blur up to 100 pixels supports soft ambient shadows for large panels and modals, as well as crisp edges for small elements.
- Negative spread: spread down to minus 20 pixels lets you tighten a shadow so it hugs the element, which is useful when a blur alone looks too diffuse.
- RGBA output: the colour and opacity are combined into a single rgba value with two decimal places for the alpha, so the copied code is complete and needs no manual conversion.
- Inset support: one checkbox adds the inset keyword at the start of the value, converting an outer shadow to an inner one without retyping.
- Neutral preview card: a white card on a light shell shows the shadow clearly, without colour or pattern distractions.
Practical Use Cases
Shadows are a quiet part of interface design. Used well, they guide attention and explain which elements can be touched or moved.
Cards on a listing page
Product cards, article cards, and profile cards usually share one gentle shadow: a small vertical offset, moderate blur, no spread, and low opacity. That consistency tells readers that all the cards sit at the same level. Build the shadow once here, then apply the same declaration to every card.
Buttons and interactive elements
A button with a small shadow looks raised and therefore clickable. Keep the offset small and the blur tight, so the button does not appear to float far above the page. For a pressed state, an inset shadow in your own stylesheet can suggest that the button has been pushed in.
Modals and dropdown menus
Overlays need a stronger shadow than ordinary cards, because they must read as sitting above everything else. A larger vertical offset and a wider blur, with slightly higher opacity, separates a modal or a menu from the dimmed page behind it. Test the result over real content, not only over the white preview.
Navigation bars and sticky headers
A header that stays at the top of the screen benefits from a thin shadow along its bottom edge. Use a zero horizontal offset, a small vertical offset, a moderate blur, and a negative or zero spread, so the shadow reads as a soft line rather than a floating box.
Inset fields and wells
Search boxes, text inputs, and recessed panels often use an inset shadow to look carved into the surface. Tick the inset option, keep the blur small, and use low opacity, so the field looks indented without looking dirty or smudged.
Tips and Best Practices
Restraint is the main skill in shadow design. A shadow should be noticed only when it is removed.
- Start soft: begin with low opacity and moderate blur, then increase slowly. It is easier to add depth than to rescue an overpowering shadow.
- Keep the light source consistent: if most shadows fall down and to the right, do not place one shadow that falls up and to the left. Consistent direction keeps the interface believable.
- Avoid pure black at full opacity: real shadows are tinted by their surroundings. A dark grey or a dark version of your brand colour at partial opacity usually looks better.
- Use one shadow scale: define two or three shadow strengths for your project, such as small, medium, and large, and reuse them. Random shadows on every element look accidental.
- Check on different backgrounds: a shadow that looks perfect on white may disappear on grey or look harsh on a photograph. Test the copied CSS in its real context.
- Respect motion and focus: shadows can change on hover to suggest lift, but keep the change subtle, and never rely on shadow alone to show keyboard focus. Use a visible outline for focus in your own code.
Limitations
This generator builds exactly one shadow. It does not support multiple comma-separated shadows, coloured glow effects built from layered shadows, or shadows that animate between states. There is no control for a hover state, a focus state, or a different shadow at different screen sizes; those variations must be written by hand in your stylesheet using the copied declaration as a starting point.
The preview shows the shadow on a single white card with a fixed shape. It cannot show how the shadow will look on a coloured card, a rounded element with a large radius, an image, or a transparent element. The opacity control applies to the whole shadow, so a shadow that needs different opacity in different directions cannot be built here. Always test the result in the real layout.
- One shadow only; no layered or multiple shadows.
- No hover, focus, or responsive variants in the output.
- Preview is a single white card; real context may differ.
- Colour is always output as rgba with the chosen opacity.
Frequently Asked Questions
What does each number in a box-shadow value mean?
In order, the values are the horizontal offset, the vertical offset, the blur radius, and the spread radius, followed by the colour. The inset keyword, when present, comes first. This tool generates the values in exactly that order, so the output can be read from left to right as offset, blur, spread, and colour.
Why is my shadow invisible?
Check the opacity slider first. At zero percent the shadow is fully transparent. Also check that the blur is not so large, and the spread so negative, that the shadow has faded to nothing. Finally, confirm that the element you pasted the CSS onto has a background and is not clipped by an ancestor with hidden overflow.
What is the difference between blur and spread?
Blur softens the edge of the shadow without changing its overall size much. Spread grows or shrinks the shadow itself in all directions before blurring. A large blur with zero spread gives a soft halo, while a positive spread with a small blur gives a larger, more solid shadow.
When should I use an inset shadow?
Use inset when the element should look pressed in rather than raised up, such as a text field, a search box, or a button in its active state. Inset shadows work best with small offsets and modest blur. For cards, menus, and modals, leave inset switched off.
Can I copy the shadow into any stylesheet?
Yes. The output is a standard box-shadow declaration with an rgba colour, supported by all modern browsers. Paste it into any rule. If your project already defines a shadow for that element, the new declaration will replace it, so check for conflicts in your stylesheet.
Shadows and Elevation Systems
Design systems often describe depth as elevation: a hierarchy of levels, from a flat page surface up through cards, menus, and modals, each with its own shadow. The idea is that elevation should be consistent, so that readers learn to read depth as meaning. A card at elevation one always uses the same gentle shadow, a dropdown at elevation two uses a stronger one, and a modal at the highest elevation uses the strongest. When shadows follow a system, depth becomes information rather than decoration.
The CSS Box Shadow Generator is a natural place to define those levels. Generate the small shadow first, with a modest offset, blur, and opacity, and record the values. Then generate the medium and large shadows, increasing the vertical offset, blur, and opacity together, so each level is clearly distinct from the one below. Three levels are enough for most products, and keeping the colour constant across levels, varying only the geometry and opacity, makes the system feel unified. Paste each shadow into a named class or variable in your stylesheet, and the whole team can use the same depths without guessing.
Related Tools
These tools cover nearby visual styling tasks that pair well with shadows.
- CSS Border Radius Generator – round the corners of the card that carries the shadow.
- CSS Background Generator – design the background behind and inside shadowed elements.
- CSS Button Generator – style buttons that use shadows to look raised.
- CSS Text Shadow Generator – add depth to text with a similar offset and blur model.
- Color Picker – choose shadow colours that match your palette.