Live Preview

Shadow Layer 1

Default

Quick Presets

What is Box Shadow Generator?

A Box Shadow Generator is a free online tool that helps web developers and designers create beautiful CSS box shadows without memorizing the syntax or experimenting with trial-and-error. The box-shadow property in CSS allows you to add shadow effects around an element's border, creating depth and dimension in your web designs. This visual builder makes it easy to adjust shadow parameters like offset, blur, spread, and color in real-time.

With our Box Shadow Generator, you can instantly see how your shadow settings affect an element and get the exact CSS code to copy into your stylesheet. Whether you need a subtle drop shadow for a card component or a dramatic layered shadow for a modal, this tool has you covered.

Understanding Box Shadow Properties

The CSS box-shadow property accepts multiple values that control different aspects of the shadow:

box-shadow: offsetX offsetY blur spread color;

Each parameter serves a specific purpose in defining the shadow's appearance.

X and Y Offset

The X offset (horizontal) and Y offset (vertical) determine where the shadow appears relative to the element. Positive values push the shadow to the right and down, while negative values move it left and up.

  • X Offset (5px): Moves shadow 5px to the right
  • Y Offset (5px): Moves shadow 5px down
  • Negative X (-5px): Moves shadow 5px to the left
  • Negative Y (-5px): Moves shadow 5px up
/* Shadow below and to the right */
box-shadow: 5px 5px 10px 0px rgba(0,0,0,0.25);

/* Shadow above and to the left */
box-shadow: -5px -5px 10px 0px rgba(0,0,0,0.25);

Blur and Spread

The blur radius controls how sharp or fuzzy the shadow edges are. A higher value creates a more diffused shadow, while zero creates a sharp, hard edge.

  • Blur (0px): Sharp, solid shadow edge
  • Blur (10px): Slightly diffused shadow
  • Blur (50px): Highly diffused, light shadow

The spread value expands or contracts the shadow size before blurring. Positive values make the shadow larger, negative values shrink it.

/* Small sharp shadow */
box-shadow: 0 2px 4px 0px rgba(0,0,0,0.1);

/* Large diffused shadow */
box-shadow: 0 10px 40px 10px rgba(0,0,0,0.2);

Color and Opacity

Shadow color is typically specified using RGBA (Red, Green, Blue, Alpha) format. The alpha channel controls opacity, allowing you to create semi-transparent shadows that blend with the background.

/* Black shadow with 25% opacity */
box-shadow: 5px 5px 10px 0px rgba(0, 0, 0, 0.25);

/* Blue-tinted shadow */
box-shadow: 5px 5px 10px 0px rgba(59, 130, 246, 0.3);

/* White shadow for dark backgrounds */
box-shadow: 5px 5px 10px 0px rgba(255, 255, 255, 0.2);

Using RGBA instead of hex with opacity gives you better browser compatibility and more precise control over the shadow appearance.

Inset vs Outset Shadows

By default, shadows appear outside the element (outset). Adding the "inset" keyword changes the shadow to appear inside the element, creating an inner shadow effect commonly used for pressed buttons, input fields, and recessed areas.

/* Outset shadow (default) */
box-shadow: 0 4px 8px rgba(0,0,0,0.15);

/* Inset shadow */
box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);

/* Input field example */
input {
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}

Multiple Shadows

CSS allows you to layer multiple shadows on a single element by comma-separating them. This technique creates more realistic and complex shadow effects that mimic natural lighting.

/* Layered shadow for depth */
box-shadow:
    0 2px 4px rgba(0,0,0,0.1),
    0 4px 8px rgba(0,0,0,0.1),
    0 8px 16px rgba(0,0,0,0.1);

/* Multiple colored shadows */
box-shadow:
    3px 3px 0px rgba(255,0,0,0.5),
    -3px -3px 0px rgba(0,0,255,0.5);

Our tool supports up to 5 shadow layers, giving you plenty of flexibility for creating complex shadow effects.

Common Box Shadow Patterns

Style CSS Value Use Case
Subtle 0 1px 3px rgba(0,0,0,0.12) Cards, subtle depth
Soft 0 4px 6px rgba(0,0,0,0.1) Buttons, hover states
Elevated 0 10px 25px rgba(0,0,0,0.15) Modals, floating elements
Heavy 0 15px 35px rgba(0,0,0,0.25) Hero sections, emphasis
Inset Light inset 0 2px 4px rgba(0,0,0,0.1) Input fields, pressed buttons
Layered 0 2px 4px, 0 4px 8px, 0 8px 16px Realistic depth effects

Browser Compatibility

The box-shadow property is supported by all modern browsers including Chrome, Firefox, Safari, Edge, and Opera. For Internet Explorer, version 9 and above support box-shadow.

For older browsers that do not support box-shadow, the shadow will simply not appear, which is safe degradation. No additional vendor prefixes are typically needed for modern development.

/* Standard syntax (works in all modern browsers) */
box-shadow: 5px 5px 10px rgba(0,0,0,0.25);

/* For older WebKit browsers (rarely needed now) */
-webkit-box-shadow: 5px 5px 10px rgba(0,0,0,0.25);
box-shadow: 5px 5px 10px rgba(0,0,0,0.25);

Best Practices

  • Use subtle shadows: Less is often more. Heavy shadows can make your design look dated.
  • Consider the background: Shadow color should complement your design. Dark shadows work best on light backgrounds.
  • Use transparency: Semi-transparent shadows (25-50% opacity) look more natural than solid black.
  • Layer for realism: Multiple subtle shadows create more believable depth than a single heavy shadow.
  • Keep performance in mind: Very large blur values can impact rendering performance on older devices.

Frequently Asked Questions

How do I create a box shadow in CSS?

Use the box-shadow property with values for offsetX, offsetY, blur, spread, and color. For example: box-shadow: 5px 5px 10px 0px rgba(0,0,0,0.25);

Can I have multiple shadows on one element?

Yes! Separate multiple shadows with commas: box-shadow: 0 2px 4px rgba(0,0,0,0.1), 0 4px 8px rgba(0,0,0,0.1);

How do I create an inner shadow?

Add the "inset" keyword before your shadow values: box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);

Why should I use RGBA for shadow color?

RGBA allows you to control opacity separately from the RGB color values, giving you more precise control over shadow transparency. This creates more natural-looking shadows that blend with the background.

What is the spread value in box-shadow?

The spread value expands or contracts the shadow before the blur is applied. Positive values make the shadow larger in all directions; negative values shrink it.

How do I make a shadow on only one side?

Use a combination of offset and blur. For a bottom shadow only: box-shadow: 0 8px 16px -4px rgba(0,0,0,0.2);