CSS Box Shadow Generator Online
Build CSS box shadows visually with live preview. Drag sliders to adjust offset, blur, spread, and color. Switch to inset mode for inner shadows. Copy the ready-to-use CSS in one click. No signup, runs entirely in your browser.
⏱ 9 min read · Complete guide below
box-shadow: 4px 8px 16px 0px #00000040;How the CSS Box Shadow Generator Works
- 1Drag the Offset X and Offset Y sliders to position the shadow — negative values move it left/up.
- 2Adjust Blur Radius for edge softness (0 = sharp) and Spread Radius to grow or shrink the shadow size.
- 3Choose a shadow color — use partial transparency (hex with alpha or rgba) for natural-looking depth.
- 4Enable Inset to flip the shadow inside the element. Click Copy CSS to get the complete declaration.
The box-shadow CSS Property
The box-shadow property accepts one or more shadow layers, comma-separated. Each shadow is defined as: [inset?] offset-x offset-y blur spread color. A box-shadow with no blur and no spread is a sharp, solid drop shadow. Adding blur spreads the shadow edges smoothly. The color's alpha channel controls how the shadow blends with the background beneath it.
Understanding the Five Values
Every box shadow is defined by up to five values plus an optional keyword, and knowing what each does turns guesswork into control. Offset-x and offset-y move the shadow horizontally and vertically — positive values push it right and down, simulating a light source from the upper left. Blur radius softens the edge: zero is a hard-edged shadow, larger values feather it out. Spread radius changes the shadow's size before blurring — positive makes it larger than the element, negative pulls it in tighter. The color, ideally with an alpha channel for transparency, sets the tone. Finally, the inset keyword flips the shadow to the inside of the element. Adjusting one value at a time in the live preview is the fastest way to build an intuition for how they interact.
Making Shadows Look Natural
The difference between an amateur shadow and a professional one usually comes down to two habits. First, use transparency, not solid color: a pure black shadow looks heavy and fake, whereas a semi-transparent one like rgba(0,0,0,0.15) blends convincingly over any background. Second, respect a consistent light source — real objects are lit from one direction, so shadows across your interface should all fall the same way (typically slightly down, with a positive Y offset). A subtle touch reads as more elegant than a dramatic one; the most polished designs often use shadows so soft you barely notice them consciously. For extra realism, layering two shadows — one small and sharp for contact, one large and soft for ambient depth — mimics how light actually behaves, a technique used in Material Design and Apple's interface guidelines.
Outer Shadows, Inset Shadows, and Performance
Switching on inset renders the shadow inside the element rather than around it, creating a concave, pressed-in look. This is perfect for the active state of a button (so it appears to sink when clicked), for input-field focus effects, and for carving depth into cards and panels. One practical caution worth knowing: box shadows can be relatively expensive to animate, because the browser repaints them on every frame as they change or as the page scrolls. If you want an animated shadow — say a lift effect on hover — the smoothest approach is often to place the shadow on a pseudo-element and transition its opacity rather than animating the box-shadow values directly, which keeps the animation on the GPU and avoids janky repaints.
Box Shadow Design Patterns
Subtle Card Elevation
Use a small Y offset, medium blur, low opacity: 0 2px 8px rgba(0,0,0,0.08). Looks natural on white cards over light backgrounds.
Hover Lift Effect
Transition from a small shadow to a larger one on hover: start with 0 2px 4px and transition to 0 8px 24px on :hover.
Layered Shadows
Stack two shadows — one close and sharp, one far and soft — for a more realistic depth. Used by Material Design and Apple's HIG.
Pressed Button State
Use an inset shadow on :active to simulate a pressed button. A small inset with dark color makes the button appear to sink in.
Glow Effect
Use a spread of 4–8px with no offset and no blur, using a bright color with some opacity: 0 0 0 6px rgba(102,126,234,0.3).
Performance Note
Box shadows are repainted on scroll and animation. For animated shadows, consider transitioning opacity on a pseudo-element shadow instead.
The Design Psychology of Shadows
Shadows do more than decorate an interface — they communicate depth, and depth is how our brains understand what is interactive and what is important. In the physical world, objects closer to us cast larger, softer shadows, so a UI element with a bigger shadow reads as “lifted” toward the viewer, while a flat element sits on the page. Designers use this instinctively: a floating action button or an open dropdown gets a pronounced shadow to signal that it hovers above everything else, while a static card gets a whisper of one.
The trend history is instructive. Early interfaces leaned on heavy, literal skeuomorphicshadows to make buttons look pressable. The flat design movement then stripped shadows away almost entirely for a cleaner look — only for designers to rediscover that some depth helps users understand hierarchy, leading to the subtle, purposeful shadows of Google's Material Design. More recently, neumorphism experimented with soft dual shadows (one light, one dark) to make elements look extruded from the background. The lesson across all of it: shadows are a language for depth, and using them with intent — not just for decoration — is what separates polished interfaces from noisy ones.
box-shadow vs Other Shadow Techniques
CSS offers more than one way to cast a shadow, and choosing the right one matters. box-shadow, the property this tool builds, applies a shadow to an element's rectangular box, respecting its border-radius — ideal for cards, buttons, panels, and anything with a defined box. But it always follows the box, which is a limitation for irregular shapes.
That is where filter: drop-shadow() comes in: unlike box-shadow, it follows the actual shape of the content, including the transparent areas of a PNG or the outline of an SVG icon, so it can shadow a logo or an irregular graphic correctly where box-shadow would just outline its bounding rectangle. Meanwhile text-shadow is the dedicated property for shadowing text. The rule of thumb: use box-shadow for rectangular and rounded UI elements, drop-shadow for irregularly shaped images and icons, and text-shadow for type. Knowing which tool fits avoids the common frustration of a shadow that stubbornly traces a box around a cut-out image.
Building a Consistent Elevation System
On a single button, any shadow that looks good is fine. Across a whole product, however, ad-hoc shadows quickly become chaotic — every card slightly different, no sense of order. Mature design systems solve this with an elevation system: a small, predefined set of shadow “levels,” each representing a height above the page. A resting card might use level 1 (a small, tight shadow), a hovered card level 2, a dropdown level 3, and a modal the highest level of all, with a large, soft shadow.
Defining these levels once as design tokens (reusable CSS custom properties like --shadow-sm, --shadow-md, --shadow-lg) and applying them consistently gives an interface a coherent, believable sense of depth, because every element that is “the same height” casts the same shadow. It also makes the system easy to maintain — adjust one token and every element at that level updates. Use this generator to design each level once, then save the values as tokens rather than hand-crafting a new shadow for every component. That discipline — a limited, intentional shadow scale rather than one-off shadows everywhere — is a hallmark of professional front-end work.
Frequently Asked Questions
What are the box-shadow parameters?
The CSS box-shadow property takes: offset-x (horizontal shift, positive = right), offset-y (vertical shift, positive = down), blur-radius (higher = softer edge), spread-radius (positive expands, negative contracts), and color. Optionally the keyword inset places the shadow inside the element instead of outside.
What is the difference between blur and spread?
Blur controls how soft the shadow's edges are — a blur of 0 gives a sharp-edged shadow. Spread controls how large the shadow is before blurring begins — positive spread makes the shadow bigger than the element, negative spread makes it smaller. You can use a negative spread with positive blur to create a subtle depth effect.
Can I add multiple shadows to one element?
Yes — CSS box-shadow accepts a comma-separated list. Each shadow is rendered from front to back. Manually edit the CSS output to add multiple shadows, e.g.: box-shadow: 0 2px 4px rgba(0,0,0,0.1), 0 10px 40px rgba(0,0,0,0.08);
What is an inset shadow?
An inset shadow renders inside the element's border instead of outside. It creates a concave appearance, as if the element is pressed in or has an inner glow. Common uses: pressed button states, input field focus rings, and depth effects on cards.
What color format should I use for shadows?
rgba() is the best choice for shadows because it allows transparency. Solid shadows look heavy and unnatural. A typical starting point is rgba(0, 0, 0, 0.15) — a 15% black shadow that blends naturally with any background color.
Is box-shadow supported in all browsers?
Yes — box-shadow has full support in every modern browser including Chrome, Firefox, Safari, Edge, and Opera, without any prefixes. It has also been supported since IE 9. No -webkit- or -moz- prefix is needed.
How do I make a box shadow look natural rather than harsh?
Two things matter most: use a semi-transparent color and keep a consistent light direction. A solid black shadow looks heavy and fake, so use something like rgba(0,0,0,0.15) that blends over any background. And since real objects are lit from one direction, make all your shadows fall the same way — usually slightly downward with a positive Y offset. Subtle shadows almost always read as more polished than dramatic ones.
What is the difference between box-shadow and drop-shadow?
box-shadow is a CSS property that applies a shadow to an element's rectangular box (respecting its border-radius). The filter: drop-shadow() function, by contrast, follows the actual shape of the content — including transparent PNGs and irregular shapes — rather than the bounding box. For standard rectangular or rounded cards and buttons, box-shadow is the right tool; for shadowing an irregularly shaped image or icon, drop-shadow is usually what you want.
Why does my shadow disappear or look clipped?
The most common cause is a parent element with overflow: hidden, which clips any shadow that extends beyond its bounds. Check the containing elements if a shadow is being cut off. Another cause is an offset or spread large enough to push the shadow outside the visible area. Reducing the offset and spread, or removing the clipping overflow on the parent, usually resolves it.
Are animated box shadows bad for performance?
They can be, because the browser must repaint the shadow on every frame as it changes, which is more expensive than compositor-only animations. For a smooth animated shadow — such as a hover lift — a common technique is to render the shadow on a pseudo-element and transition its opacity instead of animating the box-shadow values directly. This keeps the work on the GPU and avoids the repaint cost, giving a much smoother result.