CSS Box Shadow Generator
CSS ToolsCreate realistic CSS box shadows — single, layered, inset, neumorphism styles. Free, private — all processing in your browser.
box-shadow: 4px 4px 15px 0px #6366f140;
The CSS Box Shadow Generator creates shadows for buttons, cards, modals, and any element that needs depth. Configure offset-x and offset-y (shadow direction), blur radius (softness), spread radius (shadow size), color (typically semi-transparent black or a tint of your background), and inset (inner shadow for pressed/carved effects). Stack multiple shadows for realistic depth — most professional UI shadows combine 2-3 layers (ambient + key light + rim). Preview live on a sample element; copy the complete box-shadow property ready to paste into your stylesheet.
Shadows are the primary visual tool for creating hierarchy in flat modern UI. Material Design popularized systematic elevation levels (0dp, 1dp, 2dp, 4dp, 8dp, 16dp, 24dp) with predefined shadows for each. Tailwind CSS ships with shadow-sm through shadow-2xl utilities. Custom shadows give your design personality — but are hard to get right without a visual editor. This tool makes shadows intuitive: drag sliders, see the result, match the depth to the context (subtle for resting cards, prominent for modals and tooltips).
CSS Box Shadow Generator — key features
Visual sliders
Drag offset, blur, spread with immediate feedback. No typing numbers.
Multi-layer shadows
Stack up to 5 shadows for realistic depth. Each with its own parameters.
Inset shadow support
Inner shadows for pressed/carved effects.
Preset elevations
Material Design levels (1dp-24dp), Tailwind presets (sm-2xl), neumorphism.
Live preview
Sample card shows shadow applied. Background color and element style adjustable.
Colored shadows
Color-match your element color for tinted shadows (softer, more natural).
Dark mode variant
Generate both light and dark mode shadows with media query wrapper.
Copy-paste CSS
Complete box-shadow value ready for your stylesheet.
How to use the CSS Box Shadow Generator
- 1
Start with a preset
Material Design elevation, Tailwind shadow, or neumorphism for quick starting points.
- 2
Adjust offset
Typically Y offset 2-8px (shadow below element). X usually 0. Higher offsets = more prominent shadow.
- 3
Set blur
2-4px for subtle, 8-16px for prominent, 20-40px for dramatic. Higher blur = softer shadow.
- 4
Fine-tune spread
Negative spread contracts shadow (crisp edge). Positive expands (broad shadow). 0 is default.
- 5
Set color and opacity
Typically black with 10-30% alpha for light mode. For colored shadows, match element color.
- 6
Add layers if needed
Single shadows look flat. Add 2-3 layers with different blur/spread for realism.
- 7
Copy CSS
Paste into your stylesheet. Test in actual context (colors, backgrounds).
Common use cases for the CSS Box Shadow Generator
UI components
- →Card elevation: Content cards floating above page. Subtle shadow for resting state, deeper for hover.
- →Buttons: Raised buttons with small shadow. Pressed state uses inset.
- →Modals and dialogs: Prominent shadow (16-24dp) to feel floating above backdrop.
- →Dropdowns and menus: Medium shadow (8dp) to distinguish from page content.
- →Tooltips: Small shadow for subtle elevation.
Visual design
- →Neumorphism: Soft UI style with double shadows (light and dark). Trendy in 2020s.
- →Glassmorphism accents: Subtle shadows behind frosted glass elements add depth.
- →Material Design: Elevation-based hierarchy. Different shadow at each level.
- →Custom brand style: Branded shadows (colored, offset, unique angle) as part of visual identity.
Interactive states
- →Hover elevation: Cards rise slightly on hover — animate box-shadow + transform:translateY.
- →Focus ring: Inset shadow or outline-alternative focus indicator for accessibility.
- →Pressed/active state: Reduced shadow or inset on press — makes button feel pushed down.
- →Disabled state: Remove shadow on disabled to emphasize flatness.
Layout hierarchy
- →Content vs navigation: Nav has lighter shadow, content is flat — creates hierarchy.
- →Modal vs page: Modal heavy shadow, page behind blurred/dim. Emphasizes modal focus.
- →Floating action buttons (FAB): Prominent shadow emphasizes FAB as primary action.
- →Stacking visualization: Cards in a stack have progressively smaller shadows.
CSS Box Shadow Generator — examples
Subtle card shadow
Resting state for content cards.
Y: 2px, blur: 4px, spread: 0, black 10%
box-shadow: 0 2px 4px rgb(0 0 0 / 0.1);
Material elevation 4
Standard raised elevation.
Multi-layer material shadow
box-shadow: 0 2px 4px -1px rgb(0 0 0 / 0.2), 0 4px 5px 0 rgb(0 0 0 / 0.14), 0 1px 10px 0 rgb(0 0 0 / 0.12);
Modal shadow (high)
Dramatic for focus.
Y: 16px, blur: 40px, spread: -8px, black 20%
box-shadow: 0 16px 40px -8px rgb(0 0 0 / 0.2);
Neumorphism (soft UI)
Light and dark shadow combination.
Dual shadow: bottom-right dark + top-left light
box-shadow: 9px 9px 16px rgb(163 177 198 / 0.6), -9px -9px 16px rgb(255 255 255 / 0.5);
Inset shadow
Pressed or carved effect.
Inset Y: 2px, blur: 4px
box-shadow: inset 0 2px 4px rgb(0 0 0 / 0.2);
Colored shadow
Blue button with tinted shadow.
Blue button, blue-tinted shadow
.button {
background: #3498db;
box-shadow: 0 4px 14px rgb(52 152 219 / 0.4);
}Hover lift effect
Shadow grows and element rises.
Resting and hover state
.card {
box-shadow: 0 2px 4px rgb(0 0 0 / 0.1);
transition: box-shadow 200ms ease, transform 200ms ease;
}
.card:hover {
box-shadow: 0 8px 24px rgb(0 0 0 / 0.15);
transform: translateY(-2px);
}Dark mode adaptation
Stronger shadow for dark backgrounds.
Light and dark mode variants
.card {
box-shadow: 0 4px 12px rgb(0 0 0 / 0.1);
}
@media (prefers-color-scheme: dark) {
.card {
box-shadow: 0 4px 12px rgb(0 0 0 / 0.5);
}
}Technical details
CSS box-shadow syntax:
``css``
box-shadow: <offset-x> <offset-y> <blur-radius> <spread-radius> <color> [inset];
Example:
``css``
box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
Values explained:
- offset-x: horizontal offset. Positive = right, negative = left. 0 = no horizontal offset.
- offset-y: vertical offset. Positive = down, negative = up. Shadows typically go down (+Y) to simulate overhead light.
- blur-radius: shadow softness. 0 = sharp edge. Higher = softer and larger.
- spread-radius: shadow size change. Positive = expand, negative = contract. Default 0.
- color: shadow color, usually with alpha (rgba(), rgb() with slash, hsl()).
- inset: inner shadow instead of outer. Makes element look pressed or carved.
Realistic multi-layer shadows:
One CSS shadow looks flat. Realistic shadows use 2-3 layers:
``css``
/* Material Design elevation 4 */
box-shadow:
0 2px 4px -1px rgb(0 0 0 / 0.2), /* key light (sharp) */
0 4px 5px 0 rgb(0 0 0 / 0.14), /* ambient (softer) */
0 1px 10px 0 rgb(0 0 0 / 0.12); /* spread (softest) */
Material Design elevations:
Shadows for different elevation levels (in dp):
- 0dp: no shadow
- 1dp: very subtle (cards at rest)
- 2dp: subtle (raised buttons)
- 4dp: medium (app bars)
- 8dp: prominent (menus, bottom sheets)
- 16dp: high (modals)
- 24dp: highest (dialogs, elevated modals)
Neumorphism:
Soft UI style using double shadows (light + dark):
``css``
background: #e0e5ec;
box-shadow:
9px 9px 16px rgb(163 177 198 / 0.6), /* dark bottom-right */
-9px -9px 16px rgb(255 255 255 / 0.5); /* light top-left */
Inset shadow (carved effect):
``css``
box-shadow: inset 0 2px 4px rgb(0 0 0 / 0.2);
Used for: input field focus, switched-off toggles, embossed areas.
Colored shadows:
Subtle color in shadow (matches element color) looks more natural:
``css``
.button-blue {
background: #3498db;
box-shadow: 0 4px 14px rgb(52 152 219 / 0.4); /* blue-tinted shadow */
}
Hover state transitions:
Animate shadow for hover effect (feels like lifting):
``css``
.card {
box-shadow: 0 2px 4px rgb(0 0 0 / 0.1);
transition: box-shadow 200ms ease, transform 200ms ease;
}
.card:hover {
box-shadow: 0 8px 24px rgb(0 0 0 / 0.15);
transform: translateY(-2px);
}
Performance:
- Animating box-shadow triggers paint, less efficient than transform/opacity.
- For high-performance animated shadows, animate a pseudo-element opacity instead.
- will-change: box-shadow can help but use sparingly (memory cost).
prefers-color-scheme:
Dark mode shadows should be different — often darker or tinted:
``css``
.card {
box-shadow: 0 4px 12px rgb(0 0 0 / 0.1);
}
@media (prefers-color-scheme: dark) {
.card {
box-shadow: 0 4px 12px rgb(0 0 0 / 0.5);
}
}
Common problems and solutions
⚠Flat-looking single shadow
A single shadow looks fake. Real-world shadows have multiple components (key light + ambient + rim). Use 2-3 layered shadows for realism. Material Design shadows are good reference.
⚠Shadow too dark on light bg
Pure black at 50% is harsh. For light backgrounds, use 5-20% alpha black. For very light/white cards, 5-10% is plenty.
⚠Wrong shadow direction
Light in real world comes from above. Shadows should go down (positive Y offset). Horizontal offset for more stylized look. Upward shadows (negative Y) look unnatural unless intentional.
⚠Overdone shadows
Too many shadows on every element = visual noise. Use shadows for hierarchy — most elements flat, only elevated elements have shadow. Reserve big shadows for modals/menus.
⚠Animating shadow performance
Animating box-shadow triggers paint every frame — less efficient than transform/opacity. For hover animations, accept the cost (usually brief); for continuous animations, consider alternatives (animate opacity of a pseudo-element).
⚠Different backgrounds ruin shadow
Shadow designed on white background looks wrong on dark. Test in actual context. Use media queries (prefers-color-scheme) to adapt.
⚠Shadow visible through transparent elements
box-shadow shows through transparent content. If you want shadow only on the rectangle: set background color.
⚠Accessibility of shadow-only focus
Do not rely on box-shadow alone for focus indication (some users have trouble seeing shadows). Pair with outline or border color change for accessible focus.
CSS Box Shadow Generator — comparisons and alternatives
box-shadow vs drop-shadow (filter): filter: drop-shadow() respects element shape (for transparent PNGs, shaped elements with clip-path). box-shadow respects the bounding box. Drop-shadow is simpler for shaped elements.
box-shadow vs text-shadow: box-shadow is for element boxes. text-shadow for text only. See CSS Text Shadow Generator.
Single shadow vs multi-layer: Single shadow looks flat. Multi-layer (key + ambient + spread) looks realistic. Professional UI uses multi-layer.
Neumorphism vs Material Design shadows: Material uses single-directional shadow for elevation. Neumorphism uses dual shadows (light + dark) for soft-UI look. Different aesthetics; Material is more universal.
box-shadow vs outline: Outline is for focus indicators. box-shadow can simulate outline (0 0 0 3px color). Outline does not take space in layout; inset shadow takes layout space. Different uses.
Colored shadow vs black shadow: Pure black shadows on colored elements can look harsh. Tinted shadows (using element color) feel more integrated. Especially for colorful elements.
Frequently asked questions about the CSS Box Shadow Generator
▶How do I create a CSS shadow?
Use the box-shadow property: box-shadow: offset-x offset-y blur spread color. Example: box-shadow: 0 4px 6px rgb(0 0 0 / 0.1) — subtle downward shadow with 10% black. Add inset keyword for inner shadows.
▶What makes a realistic shadow?
Multiple layers. One shadow looks fake. Real shadows have multiple components: key light (sharp), ambient (softer), rim (subtle spread). Material Design shadows combine 3 layers. Tools like this generator let you stack shadows.
▶Why is my shadow not showing?
Common causes: (1) Shadow color is transparent (rgba with 0 alpha). (2) Spread is very negative, shrinking shadow inside element. (3) Element has overflow:hidden cutting off shadow. (4) Parent has transform (creates new stacking context that can cut shadows).
▶What is inset shadow?
Inner shadow instead of outer. Used for: pressed button states, carved effects, switched-off toggles, input field focus. Syntax: box-shadow: inset 0 2px 4px rgb(0 0 0 / 0.2).
▶What is neumorphism?
A soft UI style (trendy 2020-2022) using dual shadows — dark shadow below-right + light shadow above-left. Creates embossed appearance. Challenging for accessibility (contrast issues).
▶How do I animate box-shadow?
Add a transition: transition: box-shadow 200ms ease. On hover/active/focus, change the shadow. Note: animating box-shadow triggers paint, less performant than animating transform. For complex animations, animate pseudo-element opacity instead.
▶Should shadows be different in dark mode?
Yes. Subtle black-at-10%-alpha shadow works in light mode. In dark mode, shadows often disappear or need to be darker. Use @media (prefers-color-scheme: dark) to adapt shadows — typically more prominent.
▶What color should shadows be?
Black with alpha for neutral. Tinted with element color for colorful elements (blue button → blue-tinted shadow). Darker than bg is the rule. For dark backgrounds, shadows may need colored or higher-opacity to be visible.
▶How do I match Material Design shadows?
Use elevation presets. Material defines shadows for specific elevation levels (1dp, 2dp, 4dp, 8dp, 16dp, 24dp). Each has specific multi-layer shadow formulas. This tool includes presets.
▶Can I have shadows on SVG or shaped elements?
Use filter: drop-shadow() instead of box-shadow for shaped elements (SVG, clip-path, rounded). drop-shadow respects the actual shape; box-shadow always follows the rectangle.
Additional resources
- MDN — box-shadow — Official box-shadow reference.
- Material Design — Elevation — Material Design elevation system.
- Tailwind CSS — Shadow — Tailwind shadow utilities reference.
- Neumorphism.io — Neumorphism CSS generator.
- CSS Box Shadow Guide (Tooleras) — Our comprehensive shadow guide.
Related tools
All CSS ToolsColor Converter
Convert between HEX, RGB, HSL, HSV, CMYK, Lab, LCH color formats
Color Palette Generator
Generate harmonious color palettes from any base color with complementary, analogous, triadic, and monochromatic schemes.
CSS Animation Generator
Build CSS keyframe animations and transitions with live preview and easing curves
CSS Border Radius Generator
Generate CSS border-radius — from simple rounded corners to organic blob shapes
CSS Clip Path Generator
Create custom CSS shapes with clip-path — polygons, circles, ellipses, SVG paths
CSS Flexbox Playground
Build flex layouts interactively — see changes live, copy production CSS
Learn more
Explore more tools
200+ free tools that run in your browser.
Browse all tools →