Creator

CSS box-shadow Explained: Offset, Blur, Spread and Inset

ToolOrbit Team 2 min readUpdated
CSS box-shadow Explained: Offset, Blur, Spread and Inset

Shadows give interfaces a sense of depth and hierarchy, lifting cards, buttons, and modals off the page. But the CSS box-shadow property packs several values into one line, and small changes have a big visual impact. The ToolOrbit CSS Box Shadow Generator lets you dial in every parameter with a live preview, then copy the exact code.

How the box-shadow property works

A box-shadow is defined by a series of values: horizontal offset, vertical offset, blur radius, spread radius, and color. The offsets move the shadow, blur softens its edges, spread grows or shrinks it, and the color, usually a semi-transparent black, sets its intensity. Adding the inset keyword draws the shadow inside the element instead of outside.

  • Horizontal and vertical offset: position the shadow on the X and Y axes
  • Blur radius: larger values create a softer, more diffuse shadow
  • Spread radius: positive grows the shadow, negative shrinks it
  • Color: use rgba with low alpha for natural, subtle shadows
  • Inset: switches the shadow to render inside the element
.card {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.input-pressed {
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

Designing a box shadow with a live preview

Adjust the sliders for offset, blur, and spread, pick a color and opacity, and toggle inset to see the difference instantly in the live preview. Once the shadow matches your design, copy the generated box-shadow rule and paste it into your CSS.

  • Set horizontal and vertical offset to choose the light direction
  • Increase blur for softer edges
  • Tune spread to size the shadow
  • Lower the color opacity for realism, then copy the code
For realistic depth, keep horizontal offset small and use a positive vertical offset, as if light comes from above. Low-opacity black almost always looks better than solid black.

Tips for layered, realistic shadows

Real-world depth often comes from stacking two or more shadows: a tight, darker one for contact and a wider, softer one for ambient light. Keep shadows consistent across your interface so elements at the same elevation share the same shadow. The ToolOrbit Box Shadow Generator makes it simple to test these combinations and copy polished results.

Reading a shadow, parameter by parameter

box-shadow: 0 8px 24px rgba(0,0,0,.12) reads as “no horizontal shift, 8px down, 24px blur, 12% black”. Offset places the shadow (0 offset = it hugs the element), blur softens it, spread grows the solid silhouette, and the color’s alpha decides intensity. Two stacked shadows — a tight, dark one for near elevation and a wider, faint one below — sell depth better than any single shadow. inset pushes the effect inside, which pairs well with pressed-button states.

  • Small blur+small offset = crisp, cheap elevation.
  • Large blur+large offset = floating cards, costly to fake by hand.
  • Keep shadows subtle: alpha under 20% reads premium; heavy black reads dated.

Tools mentioned

More reading

View all guides
HEX vs RGB vs HSL: Which Color Format to Use
Creator

HEX vs RGB vs HSL: Which Color Format to Use

HEX, RGB and HSL describe the same colours in three ways. Here is how each one works and when each is the easier choice in CSS and design tools.

2 min readUpdated
How CSS Gradients Work: Angles, Color Stops and Examples
Creator

How CSS Gradients Work: Angles, Color Stops and Examples

How linear and radial CSS gradients are built, what the angle really means, how colour stops are placed, and tips for gradients that look good.

2 min readUpdated
CSS border-radius Explained: One, Two and Four Values
Creator

CSS border-radius Explained: One, Two and Four Values

How the CSS border-radius property works and how its one-, two- and four-value shorthand maps to each corner.

2 min readUpdated
CSS Border Radius: 15 Copy-Paste Examples
Developer

CSS Border Radius: 15 Copy-Paste Examples

15 modern CSS border radius examples: rounded cards, pills, circle avatars, asymmetrical organic blobs, and fancy 8-value border radius shapes.

3 min readUpdated
What Is Base64? How Encoding Works and Common Mistakes
Developer

What Is Base64? How Encoding Works and Common Mistakes

What Base64 encoding actually does, where it is used, and the mistakes that cause broken or oversized output.

2 min readUpdated
encodeURI vs encodeURIComponent: Which One to Use
Developer

encodeURI vs encodeURIComponent: Which One to Use

How percent-encoding works, the difference between encoding a whole URL and a single component, and the mistakes that break links.

2 min readUpdated
What Is a UUID? Version 4 vs Version 7 Explained
Developer

What Is a UUID? Version 4 vs Version 7 Explained

What a UUID looks like, why version 4 is the safe default, when version 7 is better, and best practices for IDs.

2 min readUpdated
How SHA-256 and SHA-512 Hashes Work: Hashing vs Encryption
Developer

How SHA-256 and SHA-512 Hashes Work: Hashing vs Encryption

What a hash function does, how to choose between SHA-256 and SHA-512, and why hashing is not encryption.

2 min readUpdated