CSS Box Shadow Generator

Design CSS box shadows visually. Adjust offset, blur, spread, and color with a live preview and ready-to-use CSS code.

Preview
10px
10px
5px
0px
40%

Key Features

layers

Visual Design

Adjust all shadow properties with sliders and see the result update instantly on the preview box.

tune

Full Control

Offset X/Y, blur, spread, color with opacity, and inset option for inner shadows.

bolt

Instant CSS

Copy the generated CSS code with one click. Works in all modern browsers.

lock

100% Offline

All processing is client-side. No server roundtrips, no data storage.

What Is a CSS Box Shadow?

The box-shadow property in CSS attaches one or more shadows to an element's box. It is part of the CSS Backgrounds and Borders Module Level 3 specification and is one of the most widely used visual effects in modern web design. A box shadow is defined by its horizontal offset, vertical offset, blur radius, spread radius, and color. The shadow follows the element's border shape — if the element has rounded corners via border-radius, the shadow respects those curves.

Box Shadow Parameters Explained

Every box shadow declaration consists of five core parameters, plus an optional inset keyword:

How It Works: CSS Shadow Syntax

The standard syntax for a single box shadow is:

box-shadow: offset-x offset-y blur-radius spread-radius color;

For an inset (inner) shadow, add the inset keyword at the beginning or end:

box-shadow: inset 2px 2px 5px 0px rgba(0,0,0,0.3);

Multiple shadows are comma-separated:

box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);

Material Design Shadow Levels

Google's Material Design specifies elevation levels that translate directly to box-shadow values. Here are the recommended shadow levels for different UI elevations:

/* Elevation 1 — Default cards and buttons */
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);

/* Elevation 2 — Floating action buttons, raised cards */
box-shadow: 0 3px 6px rgba(0,0,0,0.15), 0 2px 4px rgba(0,0,0,0.12);

/* Elevation 4 — Menus, sub menus */
box-shadow: 0 6px 12px rgba(0,0,0,0.15), 0 4px 8px rgba(0,0,0,0.12);

/* Elevation 8 — Dialogs, drawers */
box-shadow: 0 12px 24px rgba(0,0,0,0.15), 0 8px 16px rgba(0,0,0,0.12);

/* Elevation 16 — Modals, pickers */
box-shadow: 0 24px 48px rgba(0,0,0,0.15), 0 16px 32px rgba(0,0,0,0.12);

Each elevation uses two shadows: a larger, softer shadow for ambient light and a smaller, sharper shadow for directional light. This technique produces realistic depth perception that mimics physical lighting.

Hover Animation Effects

Transitioning box-shadow on hover creates a polished interactive feel. Always transition the box-shadow property with a short duration for smooth animation:

.card {
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
  transition: box-shadow 0.3s ease-in-out;
}
.card:hover {
  box-shadow: 0 14px 28px rgba(0,0,0,0.2), 0 10px 10px rgba(0,0,0,0.18);
}

Performance: GPU Compositing vs Repaint

Box shadows have performance implications that every developer should understand. The browser must calculate the shadow for every pixel at the element's edges, and any change to the shadow triggers a repaint. However, when combined with transform or opacity transitions that use GPU compositing, shadow-heavy animations can still run at 60fps. For complex pages with dozens of shadow elements, prefer filter: drop-shadow() for irregular shapes or limit the number of layered shadows per element. Modern browsers optimize box-shadow rendering via hardware acceleration where possible, but multiple large shadows on overlapping elements can still cause layout thrashing.

Using Pseudo-Elements for Advanced Shadows

When you need shadows that don't conform to the element's box shape — for example, shadows that extend only in one direction or glow effects with unusual shapes — CSS pseudo-elements (::before and ::after) offer an alternative approach:

.button {
  position: relative;
}
.button::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 10%;
  width: 80%;
  height: 20px;
  background: radial-gradient(ellipse, rgba(0,0,0,0.3), transparent);
  filter: blur(4px);
  z-index: -1;
}

This technique is especially useful for creating glow effects, long shadows, and custom shadow shapes that the standard box-shadow property cannot achieve.

Common Use Cases

Best Practices

Related Resources

Frequently Asked Questions

Getting Started
What is a CSS box shadow generator?expand_more
A CSS box shadow generator is a visual tool that helps you create box-shadow CSS code without manual coding. Adjust properties with sliders and see the result instantly.
Is this tool free?expand_more
Yes. All tools are completely free and run locally in your browser.
Usage
What is the difference between outer and inset shadows?expand_more
An outer shadow (default) appears outside the element's border. An inset shadow appears inside the element, creating a recessed or pressed-in effect. The inset keyword enables this.
What does spread do?expand_more
Spread expands or contracts the shadow size. Positive values make the shadow larger, negative values make it smaller. Combined with blur, it controls the shadow's reach.