Skip to main content
BS

Box Shadow Generator

Build pixel-perfect box shadows with live preview — control offsets, blur, spread, colour, and opacity, then copy the CSS in one click.

Did you like the tool? Thanks!
Share:

More CSS Tools


    

How to Use Box Shadow Generator

Design CSS box shadows visually without memorising syntax. Five sliders give you total control over horizontal offset, vertical offset, blur radius, spread radius, and shadow opacity. A colour picker sets the shadow colour, and an inset toggle switches between drop shadows (outside the element) and inner shadows. The preview box sits right below the controls, updating on every slider drag or colour change, so you see exactly what your shadow looks like before you paste it into your stylesheet. When you are happy with the result, click Copy CSS to grab the complete box-shadow declaration — including the inset keyword if enabled, and the rgba colour with your chosen opacity.

About Box Shadow Generator

The box-shadow property is one of those CSS workhorses that does far more than most developers give it credit for. At first glance it seems simple — you want a drop shadow behind a card, so you write `box-shadow: 0 4px 12px rgba(0,0,0,0.15)` and move on. But box-shadow can do layered shadows for realistic depth, coloured glows for neon effects, and inset shadows for recessed or pressed-in looks. It accepts up to six values: horizontal offset, vertical offset, blur radius, spread radius, colour, and the optional `inset` keyword. Getting the combination right by trial and error in a text editor — save, refresh, squint, tweak, repeat — is a frustrating loop that this tool eliminates by giving you real-time visual feedback on a live preview box. Understanding what each parameter does is key to using this tool effectively. The horizontal offset shifts the shadow right (positive values) or left (negative values) along the x-axis. The vertical offset shifts it down (positive) or up (negative) — this is the parameter that creates the illusion of a light source, because shadows cast downward suggest overhead lighting and shadows cast upward suggest light from below. The blur radius controls how soft or hard the shadow edge appears: a value of zero gives a crisp, sharp-edged shadow that looks like a flat duplicate of the element, while higher values spread the shadow's edge into a smooth, gradual fade — the Gaussian blur that gives modern UI its signature softness. The spread radius is the parameter most people discover last, and it is a genuine design superpower. Positive spread values cause the shadow to grow larger than the element — this lets you create a shadow that extends beyond the box without making the blur radius enormous, which would wash out the colour. Negative spread values shrink the shadow inward, which is how you create the optical illusion of an element sitting inside a recessed area when combined with the inset keyword. The inset toggle switches the shadow from an outer drop shadow (the default, where the shadow appears outside the element's border box) to an inner shadow that renders inside the element. Inset shadows are the foundation of skeuomorphic design details — they make buttons look pressed when clicked, make input fields look recessed into the page, and create the inner glow that makes glassmorphism effects pop. Combining multiple box-shadow declarations separated by commas (a feature supported by CSS but deliberately kept single-shadow in this tool to keep the interface simple) lets you stack shadows for complex lighting. Each shadow in a comma-separated list is rendered from back to front, with earlier shadows appearing behind later ones — this is the technique behind the popular "layered shadow" trend where a series of increasingly softer, larger shadows of the same colour create a smooth gradient-like depth effect that feels more natural than a single shadow. All colour handling uses rgba so you can control opacity independently from hue. The alpha channel slider on this tool gives you a 0-to-1 range that maps directly to the fourth value in `rgba(r, g, b, a)`. Lowering opacity is usually the better way to make a shadow feel subtle — a pure black shadow at 0.08 opacity looks infinitely more natural than a grey shadow at full opacity because shadows in the real world are not flat grey shapes; they are semi-transparent darkening of whatever surface they fall on. The blur radius and spread radius values are always expressed in pixels (`px`) because shadows tied to viewport units or percentages behave unpredictably across screen sizes — a 4px blur on a 320px-wide mobile screen is the same physical softening as on a 2560px desktop monitor, which is exactly what you want for UI consistency. Browser support for box-shadow is universal across all modern browsers, going back to IE9 with the standard syntax. Vendor prefixes (`-webkit-box-shadow`, `-moz-box-shadow`) have not been needed for over a decade, but this tool outputs the unprefixed standard property. For older projects, you can prefix manually if needed. The `inset` keyword must appear either at the beginning or the end of the value list — this tool places it at the beginning for readability, producing `box-shadow: inset 5px 5px 15px rgba(0,0,0,0.3)` rather than the equally valid `box-shadow: 5px 5px 15px rgba(0,0,0,0.3) inset`. Performance-wise, box-shadow can trigger repainting when animating because the browser must recalculate the shadow bitmap for every frame — animating the `transform` property instead and using box-shadow only for static styling is the recommended optimisation pattern. If you are building a shadow-heavy UI with dozens of cards each having their own shadow, be aware that large blur radii and multiple stacked shadows increase the GPU fill cost, especially on low-end mobile devices. This tool lets you preview the exact pixel values so you can make informed decisions about how heavy a shadow to use in production.

Details & Tips

Technical breakdown of each parameter and how this tool handles it: **Horizontal offset:** A signed pixel value, range -50 to 50. Positive pushes the shadow to the right; negative pushes it to the left. At zero, the shadow is centred horizontally. This tool uses a range slider for visual coarse adjustment paired with a number input for exact values — you can type -23.5 if you need fractional precision, but the output CSS rounds to the nearest integer pixel because sub-pixel shadow offsets cause anti-aliasing inconsistencies across browsers. **Vertical offset:** Same range as horizontal (-50 to 50). Together with the horizontal offset, this defines the apparent light-source direction. A shadow at (5px, 10px) looks like light is coming from top-left; a shadow at (0px, -5px) looks like light is from below. A shadow at (0px, 0px) with a blur and spread creates a uniform glow in all directions — useful for focus rings and neon outlines. **Blur radius:** Range 0 to 100px. At zero, the shadow has a hard edge — identical in shape to the element's border box, merely translated by the offsets. At 100px, the shadow edge is extremely soft, fading over a 100px gradient. The blur is implemented by browsers using a Gaussian-like kernel; the exact filter varies by engine but the visual result is consistent enough for design purposes. Note that the blur radius contributes to the total size of the shadow: a 100px blur creates a shadow that extends 100px beyond the element boundary, which you can compensate for with a negative spread. **Spread radius:** Range -50 to 50px. This is the least intuitive parameter and the most powerful. Spread effectively scales the shadow shape outward (positive) or inward (negative) before the blur is applied. A spread of 10px and a blur of 0px creates a solid 10px border of shadow around the element. A spread of -10px shrinks the shadow so it is smaller than the element itself, which only makes visible sense with a non-zero blur and inset mode. **Shadow colour and opacity:** The colour picker sets the RGB components; the opacity slider sets the alpha channel. The CSS output uses `rgba()` functional notation, e.g. `rgba(0, 0, 0, 0.25)`. The colour picker always produces a full-opacity 6-digit hex which is then combined with the alpha slider value to produce the rgba string. This separation is important because a colour picker with its own alpha channel (supported by `<input type="color">` in some browsers) behaves inconsistently across platforms — keeping opacity as a separate slider ensures the tool works identically in Chrome, Firefox, Safari, and Edge. **Inset toggle:** A checkbox that prepends the `inset` keyword to the box-shadow value. When unchecked, the default `box-shadow: ...` is produced. When checked, `box-shadow: inset ...` is produced. This is implemented as a simple conditional prefix in the CSS generation function. **Preview box:** A 200×200px div with a white background and a light border so you can see the shadow clearly against both light and dark surfaces. The box-shadow style is applied directly via Alpine's `:style` binding, so the preview updates synchronously with every slider change. **Copy behaviour:** A single Copy CSS button copies the complete CSS declaration (e.g. `box-shadow: 5px 10px 20px 0px rgba(0,0,0,0.3);`) to the clipboard. The confirmation label changes to `Copied!` for 2 seconds. **Edge cases handled:** - All zeros with opacity zero produces `box-shadow: 0px 0px 0px 0px rgba(0,0,0,0)` — a valid CSS value that renders nothing. - Negative blur radius is not valid CSS; the slider clamps to 0 minimum. - Very large spread combined with very large blur can create shadows that extend beyond the preview container; the preview box has `overflow: visible` on its parent to avoid clipping the shadow. - The rgba function wraps around the alpha value: values above 1 clamp to 1, values below 0 clamp to 0.

Frequently Asked Questions

What does the box shadow generator do?
It lets you visually design a CSS box-shadow by adjusting sliders for horizontal offset, vertical offset, blur radius, spread radius, shadow colour, and opacity. A live preview shows the result, and a Copy CSS button gives you the complete declaration ready to paste into your stylesheet.
What is the difference between blur radius and spread radius?
Blur radius controls how soft or sharp the shadow edge is — higher values make the edge fade gradually into transparency. Spread radius controls how much larger or smaller the shadow is than the element itself — positive spread grows the shadow, negative spread shrinks it inward.
What does the inset checkbox do?
It switches the shadow from an outer drop shadow (the default) to an inner shadow that renders inside the element. Inset shadows are commonly used for pressed button effects, recessed input fields, and inner glows.
Why does the tool use rgba instead of a hex colour?
The rgba format allows you to control opacity separately from colour. This is important because realistic shadows in nature are semi-transparent darkening, not flat opaque grey shapes. The alpha channel lets you dial in exactly how subtle or bold the shadow appears.
Can I create multiple shadows stacked together?
CSS supports multiple comma-separated box-shadow values on a single element. This tool generates a single shadow to keep the interface simple, but you can copy multiple shadows, combine them with commas, and paste the combined value into your CSS.
What range of values can I use for each slider?
Horizontal and vertical offset range from -50px to 50px. Blur radius ranges from 0 to 100px. Spread radius ranges from -50px to 50px. Opacity ranges from 0 to 1 in steps of 0.01. You can type values outside these ranges into the number inputs for extreme effects.
Does box-shadow affect element layout?
No — box shadows are purely visual and never take up space in the document flow. The element keeps its original size and position regardless of how large the shadow is, which is different from `filter: drop-shadow()` which can extend the paint area differently.
What is the performance impact of box-shadow?
Box-shadow triggers repainting when animated because the browser must recalculate the shadow bitmap each frame. For animations, prefer `transform` and `opacity` which run on the compositor thread. Use box-shadow only for static styling, or pair it with `will-change: box-shadow` if animation is necessary.
Do I need vendor prefixes for box-shadow?
No — box-shadow has been supported unprefixed in all major browsers since roughly 2011. The `-webkit-box-shadow` and `-moz-box-shadow` prefixes are no longer needed for modern web development.
Can I use percentage or em values for shadows?
Technically yes, but it is not recommended. Shadows defined in relative units change size when the viewport or font size changes, leading to inconsistent appearance across devices. Pixel values ensure your shadow looks the same on every screen.
Is my data sent to a server?
No — the entire shadow generator runs in your browser using JavaScript. Nothing you type or design is transmitted anywhere.
What happens if I set all sliders to zero?
You get an invisible shadow — `box-shadow: 0px 0px 0px 0px rgba(0,0,0,0)`. This is valid CSS that renders nothing, and can be useful as a placeholder or reset value in your stylesheet.

Also Available As

box shadow generator, css box shadow, box shadow css, shadow builder, css shadow generator, drop shadow css, inset shadow, box shadow preview, shadow effect generator, rgba shadow, layered shadow css

Found a Problem?

Let us know if something with Box Shadow Generator isn't working as expected.

Thanks — we'll take a look.