CSS Box Shadow Generator - Create & Preview Shadows

Generate CSS box shadows with live preview

Box Shadow Generator

Presets
Shadow Layers
Offset & Size
X Offset 0px
Y Offset 4px
Blur 12px
Spread 0px
Color & Options
Shadow Color
Opacity 0.20
Inset (inner shadow)
Preview Shape
Background
200 x 200
Generated CSS

How CSS Box Shadow Works

The CSS box-shadow property adds shadow effects around an element's frame. It accepts values for horizontal offset, vertical offset, blur radius, spread radius, and color. You can stack multiple shadows in a single declaration for more realistic depth.

Syntax:

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

What each value controls:

  • Offset X/Y: Where the shadow appears. Positive X moves right, positive Y moves down. Both at zero centers the shadow behind the element.
  • Blur: Softness of the shadow edge. A value of 0 creates a sharp edge. Higher values create a more diffused shadow using Gaussian blur.
  • Spread: Expands (positive) or contracts (negative) the shadow before blur. Negative spread is commonly used to keep shadows tighter than the element.
  • Color: Always specify explicitly. Use rgba() for transparency -- most shadows use opacity between 0.1 and 0.25.
  • Inset: Renders the shadow inside the element. Creates a recessed or pressed-in appearance instead of elevation.

Why layer multiple shadows?

Real lighting produces both ambient (soft, spread-out) and direct (tight, defined) shadows simultaneously. A single shadow looks flat. Combining a large soft shadow with a smaller sharp one creates realistic depth. This is why most design systems use two-layer shadows for card elevation.

Performance tip: Large blur values (50px+) cost more to render. If animating shadows, apply the shadow to a pseudo-element and transition its opacity instead of changing shadow values directly.

Read the full guide: CSS Box Shadow Explained -- covers syntax details, layering techniques, common patterns, and performance tips.

FAQ

What is the CSS box-shadow property?

The box-shadow property adds shadow effects to an element's frame. It accepts horizontal offset, vertical offset, optional blur radius, optional spread radius, and color. Multiple shadows can be comma-separated in one declaration.

How do I add multiple shadows to one element?

Separate each shadow with a comma. The first shadow renders on top (closest to the viewer). Example: box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);

Does box-shadow affect element size or layout?

No. Box shadows are purely visual and do not change the element's dimensions or affect document flow. This is why they are useful for focus indicators as an alternative to border.

How do I create an inner shadow in CSS?

Add the inset keyword: box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);. The shadow renders inside the element instead of outside.

What is the difference between box-shadow and drop-shadow?

box-shadow always creates a rectangular shadow. filter: drop-shadow() follows the element's actual visible shape, including transparent areas. Use drop-shadow() for non-rectangular shapes like icons.

How do I make a shadow appear only on one side?

Use offset to push the shadow in one direction and negative spread to clip the other sides. Bottom-only: box-shadow: 0 4px 6px -6px rgba(0, 0, 0, 0.3);

Can I animate box-shadow?

Yes, but it triggers a repaint on every frame. For better performance, apply the shadow to a ::after pseudo-element and transition its opacity instead.

Does box-shadow follow border-radius?

Yes. The shadow automatically matches the element's border-radius, producing rounded shadow edges for rounded elements.

What color should I use for shadows?

Semi-transparent black works for most cases: rgba(0, 0, 0, 0.1) to rgba(0, 0, 0, 0.25). Avoid high opacity -- real shadows are subtle. For colored surfaces, tinting the shadow with the background color looks more natural.

Is box-shadow supported in all browsers?

Yes. All modern browsers support box-shadow without vendor prefixes, including Chrome, Firefox, Safari, Edge, and mobile browsers.

Related Tools

Privacy & Limitations

  • All calculations run entirely in your browser -- nothing is sent to any server.
  • Results are computed locally and should be verified for critical applications.

Related Tools

View all tools

Box Shadow Generator FAQ

What is Box Shadow Generator?

Box Shadow Generator is a free developer tools tool that helps you Generate CSS box shadows with live preview and layered effects.

How do I use Box Shadow Generator?

Enter your input values, review the calculated output, and adjust inputs until you reach the result you need. The result updates in your browser.

Is Box Shadow Generator private?

Yes. Calculations run locally in your browser. Inputs are not uploaded to a server by default, and refreshing the page clears session data.

Does Box Shadow Generator require an account or installation?

No. You can use this tool directly in your browser without sign-up or software installation.

How accurate are results from Box Shadow Generator?

This tool applies standard formulas or deterministic processing logic for estimates. For medical, legal, tax, or investment decisions, verify with a qualified professional.

Can I save or share outputs from Box Shadow Generator?

You can bookmark this page and copy outputs manually. Results are not persisted in your account and are typically not embedded in the URL.

Request a New Tool
Improve This Tool