ximg.es

Box-shadow generator

Design the shadow for an image, a card or a button with the controls and copy the CSS. Supports multiple layers and inset shadows, and the page link stores the shadow so you can share it.

CSS code

box-shadow:
  0 10px 25px -5px rgba(0, 0, 0, 0.25),
  0 8px 10px -6px rgba(0, 0, 0, 0.1);

The sample image is an ximg.es placeholder: /480x300/2563eb/ffffff.png?text=box-shadow

Presets
Layers

How box-shadow works

The box-shadow property draws one or more shadows around an element's box. Each shadow is written in this order:

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

Multiple shadows on one element

Shadows are separated by commas and the first one sits on top. Combining a short, crisp shadow with a wide, soft one looks far more natural than a single dark shadow: that is what the Raised and Layered presets do.

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

Shadows on images: box-shadow or drop-shadow

box-shadow follows the shape of the box, including its border-radius, so it is what you need for photos and cards. If the image is a PNG or SVG with a transparent background and you want the shadow to follow the outline of the drawing, use the drop-shadow() filter:

img.logo { filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3)); }

drop-shadow() has no spread or inset, and does not take comma-separated layers.

Tips

Frequently asked questions

What is box-shadow in CSS?

It is the property that adds shadows to an element's box. It takes offsets, blur, spread, colour and the inset keyword, and several shadows can be applied separated by commas. It works in every current browser without prefixes.

How do I add a shadow only at the bottom?

Use a positive vertical offset and a negative spread about the size of the blur, so the shadow does not show on the sides: box-shadow: 0 8px 6px -6px rgba(0, 0, 0, 0.3);

How do I make an inner shadow?

Put inset first: box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.2);. It is handy for form fields and pressed buttons.

Can I use several shadows at once?

Yes, separated by commas. The first one in the list is painted on top. In this generator, each shadow is a layer.

Why is the shadow of my transparent PNG square?

Because box-shadow follows the element's box, not the drawing. To follow the silhouette, use filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3)).

Does box-shadow hurt performance?

A static shadow costs very little. What is expensive is animating it or using very large blurs on many elements, because it forces repaints. For animations, change the opacity of a pseudo-element with the shadow.

More tools

See all tools · Placeholder image generator