Free CSS Box Shadow Generator

Adjust sliders, pick a color, and get perfect CSS box shadow code instantly. Live preview updates as you type. Free, no sign-up required.

Build Your Box Shadow

4px
8px
24px
0px
20%
shadow inside element
Preview
CSS Output
box-shadow: 4px 8px 24px 0px rgba(0, 0, 0, 0.20);

Level Up Your Design Components

These widgets help thousands of websites look polished and convert better.

Explore More Free Design Tools

Other free tools to help you design and build faster.

How It Works

How to use this free box shadow generator

No account needed, no sign-up required. Completely free. Drag the sliders, pick a color, and copy your shadow CSS in seconds.

1

Adjust the shadow sliders

Use the horizontal offset, vertical offset, blur radius, and spread radius sliders to shape your shadow. Values update the live preview instantly so you can see exactly what your shadow will look like in a real browser.

2

Pick a color and opacity

Choose any shadow color using the color picker. Control transparency with the opacity slider to create subtle shadows for cards or dramatic shadows for hero elements. The tool converts your values to rgba automatically.

3

Copy the CSS and paste it in

Click Copy CSS to copy the complete box-shadow property to your clipboard. Paste it directly into your stylesheet, CSS-in-JS file, or inline style. No account needed, completely free.

CSS Syntax

The CSS box-shadow property syntax

Understanding the syntax makes it easy to hand-tune shadows once you have a starting point from this free generator.

CSS Syntax

box-shadow: [inset] h-offset v-offset blur spread color;

Example: box-shadow: 0 4px 24px 0 rgba(0, 0, 0, 0.12);

The h-offset and v-offset are required. All other values are optional and default to 0 or transparent if omitted. Positive h-offset moves the shadow right; positive v-offset moves it down. Negative values go left and up.

The blur radius starts from the shadow edge and blurs outward. It cannot be negative. The spread radius controls the overall size of the shadow before blurring. A spread of 0 matches the element exactly. A negative spread shrinks the shadow, which is useful for creating tight contact shadows.

You can stack multiple shadows on a single element by separating them with commas. The first shadow in the list renders on top. This technique is commonly used to create layered depth: one tight shadow near the element for contact shadow, and one distant soft shadow for ambient light.

The inset keyword, when added before the offsets, renders the shadow inside the element. Inset shadows are clipped by the element border and do not extend outside it. They are ideal for indicating focus, active, or pressed states on inputs and buttons.

Shadow Examples

Ready-to-use box shadow examples by use case

Copy any of these values directly or use them as a starting point in the generator above.

Style NameCSS ValueBest For
Subtle card lift0 2px 8px rgba(0,0,0,0.08)Cards, panels, light UI elements
Medium depth0 4px 24px rgba(0,0,0,0.12)Modals, dropdowns, popovers
Strong elevation0 8px 40px rgba(0,0,0,0.2)Floating action buttons, headers
Colored glow0 0 20px rgba(76,79,255,0.4)Brand highlights, CTAs, badges
Inset pressedinset 0 2px 6px rgba(0,0,0,0.15)Active inputs, pressed buttons
Hard edge4px 4px 0px rgba(0,0,0,0.85)Retro UI, comic style, neo-brutalism

All values are production-ready. Copy and adapt to your design system.

Browser Support

CSS box-shadow browser compatibility

Box-shadow is universally supported in all modern browsers. Here is the full compatibility breakdown for production use.

BrowserSupport LevelSince VersionNotes
ChromeFull support10+Full support including multiple shadows
FirefoxFull support4+Full support including spread and inset
SafariFull support5.1+Full support. Requires -webkit- prefix for Safari 3-4.
EdgeFull support12+All Edge versions support box-shadow fully
IEPartialIE 9+IE 9+ supports box-shadow. IE 8 requires filter hack.
iOS SafariFull support5+Full mobile browser support

Source: MDN Web Docs, Can I Use. Data as of 2026.

Common Mistakes

Six CSS box shadow mistakes that kill your UI polish

Most shadow problems stem from a few repeated habits. Avoiding these mistakes instantly elevates your design quality.

💣

Using only black shadows

Pure black shadows rarely appear in real-world interfaces. They look harsh and artificial. Pick a color that is slightly tinted toward your background or brand hue. Dark navy or brown shadows read far more naturally than rgb(0,0,0).

Use rgba shadows with 10-25% opacity for realism
⛏️

Making shadows too hard-edged

A blur of 0 creates a harsh, unrealistic shadow that draws attention to itself. Most UI shadows need at least 4-8px of blur to look natural. Hard shadows work for intentional neo-brutalist aesthetics only.

Aim for blur radius 2x your v-offset as a starting point
🖼️

Applying the same shadow to everything

A flat design with identical shadows on all elements destroys depth hierarchy. Cards, modals, and floating buttons should have progressively larger shadows. Use 3-4 elevation levels across your UI system for visual clarity.

Define 3-4 shadow tokens in your design system

Animating box-shadow directly

Animating box-shadow triggers layout repaints on every frame, which is expensive on mobile. Instead, animate opacity on a pseudo-element with the target shadow applied. This keeps animations on the GPU compositor.

Use opacity animation instead of box-shadow transitions
📱

Forgetting mobile dark mode

Shadows built for light mode often disappear in dark mode because dark backgrounds absorb dark shadows. Add a second shadow value with a lighter, semi-transparent color, or use CSS custom properties to swap shadow values for dark mode.

Test every shadow in both light and dark mode
🔍

Overusing multiple shadow layers

Multiple stacked box shadows can create beautiful effects, but each additional shadow layer increases paint complexity. Keep layered shadows to 2-3 maximum and avoid them on elements that appear hundreds of times on a page.

Limit layered shadows to key focal elements only

Design Tips

8 tips to use box shadows like a pro

These techniques help you create polished, consistent depth effects across your entire site. All CommonNinja widgets mentioned are free to start.

01

Create depth hierarchy with elevation tokens

Define 3-4 named shadow levels (low, medium, high, overlay) and apply them consistently. This makes your UI feel cohesive and gives users clear visual cues about which elements are interactive or elevated.

02

Match shadow direction to your light source

Pick one consistent light source direction (top-left is most common) and apply it to all shadows. Inconsistent shadow angles across a page create subconscious visual tension that makes interfaces feel amateurish.

03

Add hover effects to lift interactive elements

Combine box-shadow transitions with translateY to create a natural lift effect on buttons and cards. Use CommonNinja Image Hover Effects to apply polished hover interactions without writing custom CSS.

Try Image Hover Effects Free
04

Use gallery shadows to frame visual content

A well-tuned card shadow on image gallery items adds polish and perceived quality. CommonNinja Image Gallery lets you display images with consistent shadow and hover behavior across your entire site.

Try Image Gallery Free
05

Layer two shadows for premium depth

Stack a close, sharp shadow (2px 2px 4px rgba(0,0,0,0.1)) with a distant, soft shadow (0 12px 40px rgba(0,0,0,0.08)). The combination mimics how real objects cast both a contact shadow and a distant ambient shadow.

06

Use colored shadows for brand moments

Swap black shadows for brand-colored glows on your most important CTAs. A blue glow on a blue button reinforces your brand identity and makes the action feel energetic rather than generic.

07

Shadow popup overlays for focus

Popups and modals need strong shadows to separate from the page. Use a high-spread, low-blur shadow (0 0 0 9999px rgba(0,0,0,0.5)) as a backdrop, or use CommonNinja Popup Builder for zero-code modal experiences.

Try Popup Builder Free
08

Define shadows as CSS custom properties

Store your shadow values in CSS variables (--shadow-md: 0 4px 24px rgba(0,0,0,0.1)) and reference them throughout your stylesheet. This makes theme switching and dark mode support trivially easy to implement.

CSS Effects Glossary

Box shadow property reference

A plain-English reference to every box-shadow parameter so you can hand-edit values confidently without a generator.

PropertyDescriptionExampleRequired?
H-OffsetHorizontal offset moves the shadow left (negative) or right (positive) relative to the element.box-shadow: 10px 0 ...Required
V-OffsetVertical offset moves the shadow up (negative) or down (positive) relative to the element.box-shadow: 0 10px ...Required
Blur RadiusControls edge softness. Zero is a hard shadow. Higher values create a more diffuse, realistic shadow.box-shadow: 0 0 20px ...Optional
Spread RadiusExpands or contracts the shadow before blurring. Positive grows it, negative shrinks it below element size.box-shadow: 0 0 0 10px ...Optional
ColorAccepts any CSS color value. Use rgba for transparency control. Tinted shadows look more natural than black.box-shadow: ... rgba(0,0,0,0.15)Optional
InsetMoves the shadow inside the element boundary, creating an inner-glow or pressed-in appearance.box-shadow: inset 0 2px 6px ...Optional

FAQ

A CSS box shadow adds a shadow effect around an element. It is defined by horizontal offset, vertical offset, blur radius, spread radius, color, and an optional inset keyword. You can stack multiple shadows separated by commas to create layered depth effects.
The blur radius controls how soft or sharp the shadow edge is. A value of 0 creates a hard, crisp shadow identical to the element shape. Higher values spread the shadow outward and make edges softer. There is no maximum limit, but values above 100px rarely produce noticeable changes.
Blur softens the shadow edges, while spread expands or contracts the entire shadow size before blurring. A positive spread makes the shadow larger than the element. A negative spread shrinks it. Both can be used together to create precise depth effects.
The inset keyword moves the shadow inside the element instead of outside. This creates a pressed-in or inner-glow appearance. Inset shadows are commonly used for inputs, buttons, and cards to indicate focus or active states.
Yes, completely free. No account, no sign-up, no limits. Adjust the sliders, preview the result, copy the CSS, and use it in any project.
Yes. CSS supports multiple shadows on a single element by separating them with commas: box-shadow: 2px 2px 4px rgba(0,0,0,0.2), -2px -2px 4px rgba(255,255,255,0.5). Layer them in this tool by copying individual shadow values and combining them manually.
Box shadows do not affect layout or take up space in the document flow. However, heavy use of box shadows on large numbers of elements can impact paint performance. Use the will-change: box-shadow CSS property sparingly on animated elements to hint at GPU compositing.

Trusted by