CSS Box Shadow Generator

Create depth and elevation for your UI components • Copy code instantly

Our CSS Box Shadow Generator lets you visually create smooth, layered, and inset shadows. Adjust offset, blur, spread, color, and opacity—then copy the box-shadow CSS code for your project. Free tool, no signup required.

Position

Blur & Spread

Color

Preview

CSS Code

What is CSS Box Shadow?

The box-shadow CSS property adds shadow effects around an element's frame. You can set multiple shadow effects separated by commas, making it possible to create complex, layered depth that mimics real-world lighting. A box shadow is described by X and Y offsets relative to the element, blur and spread radius, and color. It is one of the most effective properties for adding depth to flat UI designs without using images.

How Box Shadow Works

The box-shadow property accepts several values that control the shadow's appearance:

  • Offset-X: Moves the shadow horizontally. Positive values push it right; negative values push it left.
  • Offset-Y: Moves the shadow vertically. Positive values push it down; negative values push it up.
  • Blur Radius: Controls how soft or sharp the shadow's edges are. A value of 0 creates a hard-edged shadow; higher values create progressively softer, more diffused shadows.
  • Spread Radius: Expands or contracts the shadow. Positive values make the shadow larger than the element; negative values shrink it.
  • Color: Defines the shadow's color. Using low-opacity colors (like rgba(0,0,0,0.15)) produces natural-looking shadows.

Types of CSS Box Shadows

S Soft Shadows

High blur, low opacity. Creates a natural, diffused look used for cards and modals.

L Layered Shadows

Multiple shadows stacked for realistic depth. Combines a sharp close shadow with a soft far shadow.

I Inset Shadows

Drawn inside the element using the inset keyword. Ideal for input fields and pressed states.

Best Practices for UI Shadows

  • Use low opacity: Shadows with 0.08–0.2 opacity look more natural than fully opaque black shadows.
  • Keep offsets small: Large X/Y offsets look unrealistic. Stick to 0–10px for modern UI elevation.
  • Layer two shadows: A sharp, close shadow (low blur) combined with a soft, distant shadow (high blur) creates convincing depth.
  • Match your palette: If you generate color palettes with cool tones, use a slightly cool-tinted shadow (like rgba(0,0,40,0.1)) instead of pure black.
  • Use inset for inputs: Inset shadows on form fields create a subtle "recessed" look that signals interactivity.

How to Use This Generator

  1. Adjust Position: Use the X and Y offset sliders to move the shadow direction.
  2. Set Blur & Spread: Increase blur for softer edges; adjust spread to resize the shadow area.
  3. Pick Color & Opacity: Choose a shadow color and lower the opacity for a natural look.
  4. Toggle Inset: Check the inset box to create inner shadows for inputs and pressed states.
  5. Copy Code: Click Copy to grab the box-shadow CSS and paste it into your stylesheet.

Need to convert HEX to RGB for your shadow color values? Use our color converter for quick format changes.

Common Mistakes in Box Shadow Usage

  • Using pure black at full opacity: This creates harsh, unrealistic shadows. Always reduce opacity to 0.15 or below.
  • Overusing large offsets: Shadows that are offset too far make elements look disconnected from the surface.
  • Ignoring dark mode: The same shadow that looks subtle on white may be invisible on dark backgrounds. Increase opacity slightly for dark themes.
  • Too many shadow layers: Three or more shadows can hurt performance on pages with many elements. Stick to two layers maximum.
  • Forgetting spread: A small negative spread (-1px to -3px) tightens the shadow and prevents it from overflowing rounded corners.

To learn color combinations that pair well with your shadow styles, check out our palette guide.

Frequently Asked Questions

What is box shadow in CSS?

The box-shadow CSS 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 also use the inset keyword to draw the shadow inside the element.

How to create smooth shadows?

Use a high blur value (20px or more), a small offset (0-5px), no spread, and a low-opacity color (0.1 to 0.25). This produces a soft, natural-looking shadow commonly used in modern UI design for cards and elevated surfaces.

What is blur and spread in box shadow?

Blur controls how soft or sharp the shadow edge is—higher values create softer, more diffused shadows. Spread controls the size of the shadow—positive values expand it beyond the element, negative values shrink it inward.

What are best shadow values for UI?

For modern UI: subtle elevation (0 1px 3px rgba(0,0,0,0.1)), card shadow (0 4px 15px rgba(0,0,0,0.1)), and prominent elevation (0 10px 40px rgba(0,0,0,0.15)). Layering two shadows with different blur values creates a more realistic depth effect.

Explore More Color Tools

Take your designs further with these resources: