CSS Box Shadow Generator
Design beautiful CSS box shadows visually with a live preview. Adjust offset, blur, spread, color, and opacity. Add multiple shadow layers and copy the generated CSS code.
Presets — click to try
About CSS Box Shadow Generator
The CSS box-shadow property adds shadow effects around an element's frame. It is one of the most versatile and widely used CSS properties for creating depth, emphasis, and visual hierarchy in modern web design. The property accepts values for horizontal offset, vertical offset, blur radius, spread radius, color, and an optional inset keyword. Multiple shadows can be applied to a single element by separating each shadow definition with a comma.
The basic syntax is: box-shadow: [inset] offset-x offset-y blur-radius spread-radius color;. The horizontal offset moves the shadow left (negative values) or right (positive values). The vertical offset moves the shadow up (negative values) or down (positive values). The blur radius softens the shadow edge — a value of 0 creates a sharp shadow, while larger values produce softer, more diffused shadows. The spread radius expands (positive) or contracts (negative) the shadow relative to the element's size.
Box shadows are essential for creating modern UI designs. Subtle shadows give cards and buttons a raised appearance, making interfaces feel more tactile and three-dimensional. Material Design, for example, relies heavily on elevation through box shadows to indicate interactive elements and content hierarchy. When using shadows, start with small, subtle values for most UI elements and reserve larger, more dramatic shadows for modal dialogs, popovers, and other elevated components.
For performance, box shadows are generally well-optimized in modern browsers, but applying very large blur values or multiple shadow layers on many elements can impact rendering speed, particularly during animations. Consider using will-change: box-shadow or transitioning opacity on a pseudo-element for smoother animations. Also, note that box shadows do not affect layout — they are purely visual and do not change the element's size or position in the document flow.
FAQ
Q: What is the difference between box-shadow and drop-shadow?
The box-shadow property applies a shadow to the element's rectangular box, regardless of its shape. The filter: drop-shadow() function, on the other hand, respects the element's alpha channel and follows the outline of non-rectangular shapes like PNG images with transparency. Use box-shadow for cards, buttons, and containers; use drop-shadow() for icons, images, or elements with irregular shapes.
Q: Can I use multiple box shadows on one element?
Yes. You can apply multiple shadows by separating them with commas: box-shadow: 0 2px 4px rgba(0,0,0,0.1), 0 8px 16px rgba(0,0,0,0.1);. Layering shadows this way creates more realistic and natural-looking depth effects. The first shadow in the list appears on top, so order matters when shadows overlap.
Q: What is an inset shadow?
Adding the inset keyword changes the shadow from an outer shadow to an inner shadow, making it appear as though the content is pressed into the page. Inset shadows are commonly used for input fields, pressed button states, and creating an embossed or engraved appearance.
Q: How do I create a shadow on only one side of an element?
To create a one-sided shadow, combine the offset and spread values strategically. For example, a bottom-only shadow can be achieved with box-shadow: 0 4px 6px -2px rgba(0,0,0,0.2); — the negative spread shrinks the shadow, and the positive vertical offset pushes it downward so only the bottom edge is visible.
Q: Does box-shadow affect element layout or size?
No. Box shadows are purely visual and do not affect the element's dimensions, position, or layout. They render outside (or inside for inset) the element's border box without changing its computed width, height, or spacing. This means adjacent elements will not be pushed away by a shadow, so ensure you leave enough margin or padding to prevent visual overlap.