CSS Tools

6 min read · January 2025

CSS Box Shadow: Complete Guide with Free Generator Tool

The CSS box-shadowproperty is one of the most powerful tools in a front-end developer's arsenal. Used well, shadows add depth, hierarchy, and a sense of elevation to UI components. This guide explains the complete syntax and shows you how to generate beautiful shadows without the trial-and-error.

The CSS box-shadow Syntax Explained

The box-shadow property accepts up to six values:

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

Here is what each value does:

Popular Shadow Presets with Code Examples

Soft Elevation (Card Shadow)

Perfect for cards, modals, and panels. A large blur with a very low opacity gives a realistic, airy feeling.

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

Subtle Lift (Button Hover)

A small shadow that appears on hover to give the impression of a button lifting off the surface.

box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);

Strong Drop Shadow

For modals, dropdowns, and popovers that need to appear clearly above other content.

box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);

Inset Shadow (Pressed Button)

Creates a depressed or "pressed in" effect. Great for active/clicked button states.

box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.15);

Multiple Shadows

CSS allows you to stack multiple shadows on a single element by separating them with commas. This technique is used to create more realistic, layered light effects:

box-shadow:
  0 1px 2px rgba(0, 0, 0, 0.07),
  0 4px 8px rgba(0, 0, 0, 0.05),
  0 12px 24px rgba(0, 0, 0, 0.03);

This three-layer shadow mimics how light naturally diffuses — a sharp, dense shadow close to the element, then softer layers extending further out. This is the technique used by Stripe, Linear, and other design-forward products.

Performance Tips

Box shadows are rendered by the browser's compositor and are GPU-accelerated, which means they are generally very performant. However, a few things to keep in mind:

Real-World Examples

Try it free →

Visually design your shadow and get copy-ready CSS code instantly.

Open CSS Box Shadow Generator

Related Tools