CSS Box Shadow Generator

Design soft, layered or inset box shadows with sliders and copy the CSS.

CSS Box Shadow Generator tool

px
Presets
Tailwind CSS class

About the CSS Box Shadow Generator

Subtle shadows give cards, buttons and dialogs depth, while heavy ones look dated, and the difference lies in a few numbers. This box shadow generator lets you adjust the horizontal and vertical offset, blur, spread, color and opacity with sliders, stack several layers for a natural soft look or switch to an inset shadow, and watch the preview update. Copy the finished box-shadow CSS or an equivalent Tailwind class straight into your project. Layering two or three low-opacity shadows usually looks more realistic than one dark shadow, which is how many modern design systems build their elevation styles.

Realistic shadows are usually made of several layers: a tight, darker shadow close to the element and a wide, faint one further away. Add as many layers as you like, switch any of them to inset for pressed or inner effects, and start from presets such as soft, subtle, floating, layered, retro, inset or glow. Each layer has its own controls, so fine-tuning stays easy.

The output uses rgba colors for transparency, a comma-separated list for multiple layers, and units only where they are needed. A Tailwind CSS arbitrary value is produced too, so you can paste the same shadow as a class. Change the preview box color, the background and the corner radius to see the shadow in the context of your own design.

Shadows pair well with rounded corners from the border radius generator and with frosted panels from the glassmorphism generator. For lettering, use the text shadow generator. Every change shows up in the preview immediately.

How to use the CSS Box Shadow Generator

  1. Pick a presetStart from soft, floating, layered, retro, inset or glow, or keep the default.
  2. Adjust the layersMove the offset, blur, spread and opacity sliders, and pick a color.
  3. Add depthAdd more layers, or tick Inset for inner shadows.
  4. Copy the CSSCopy the box-shadow declaration or the Tailwind class.

CSS Box Shadow Generator features

  • Sliders for offset, blur, spread and opacity
  • Any number of shadow layers
  • Inset shadows
  • Presets: soft, subtle, floating, layered, retro, glow
  • rgba colors with transparency
  • Tailwind arbitrary value output
  • Preview box color, background and radius
  • Instant live preview

Common uses

  • Styling cards, modals and dropdown menus
  • Creating elevation levels for a design system
  • Making buttons look pressed with inset shadows
  • Adding glow effects to highlighted elements
  • Learning how box-shadow values work

Box shadows in practice: an elevation scale, one light source, coloured shadows, dark mode, clipping and focus rings

By the FreeToolsWorld editorial team · Updated November 2026 · How we write and check our guides

Shadows tell people which parts of an interface sit above others: a card above the page, a menu above the card, a dialog above everything. Used consistently, they make interfaces easier to understand; used randomly, they make pages look muddy. This guide builds a three-level elevation scale and then covers light direction, coloured shadows, dark mode, shadows that get clipped, cheaper hover effects, focus rings and shadows for irregular shapes.

A worked example: an elevation scale

A design system defines three shadow levels as custom properties and uses nothing else:

  • Level 1, resting cards: 0 1px 2px rgba(15,23,42,.08), 0 1px 3px rgba(15,23,42,.06).
  • Level 2, hovered cards and dropdowns: 0 4px 12px rgba(15,23,42,.10).
  • Level 3, dialogs: 0 20px 40px rgba(15,23,42,.18).

Stored as --shadow-1 to --shadow-3, these give every component the same depth language. A card that lifts to level 2 on hover feels clickable, and a dialog at level 3 clearly floats above everything else.

One light source

Real light comes from one direction, so shadows across a page should all fall the same way, usually downwards with a small vertical offset. A layout where one card's shadow falls left and another's falls down looks subtly wrong even to people who cannot say why. Keeping horizontal offsets at zero is the simplest way to stay consistent.

Coloured shadows

Pure black or grey shadows look dirty on coloured backgrounds. Tinting a shadow with the hue of the element or the background, for example a blue button casting rgba(37,99,235,.35), looks more natural and more vivid. On white pages, a very dark blue-grey rather than pure black gives softer, more pleasant shadows.

Dark mode

Shadows almost disappear on dark backgrounds, because there is little darker to fall onto. Dark interfaces usually show elevation by making raised surfaces slightly lighter instead, sometimes with a faint border. Defining separate shadow and surface values for dark mode keeps depth visible in both themes.

Shadows that get clipped

A parent with overflow: hidden cuts off the shadows of its children, a common reason a carefully designed shadow seems to vanish inside a slider or scroll area. Adding padding to the container gives the shadow room, or the overflow rule can move to an inner element that does not hold the shadowed items.

Cheaper hover effects

Animating box-shadow forces the browser to repaint the element on every frame, which can stutter on low-end phones. A common technique places the larger hover shadow on a pseudo-element behind the card and animates only that element's opacity, which browsers handle far more efficiently. The visual result is the same.

Focus rings

A shadow such as 0 0 0 3px rgba(37,99,235,.5) makes a neat focus ring that follows rounded corners. Windows high contrast mode removes shadows, however, so keep a transparent outline as well, for example outline: 2px solid transparent, which becomes visible in that mode while staying invisible normally.

Shadows for irregular shapes

box-shadow always follows the element's rectangular box, even when the image inside is a cut-out product photo or icon with transparent areas. The filter: drop-shadow() function follows the visible shape instead, which suits logos, cut-out product photos and illustrations.

Common mistakes

  • Using a different, improvised shadow on every component.
  • Mixing light directions on one page.
  • Expecting shadows to show on dark backgrounds.
  • Animating large shadows directly on low-end devices.

Related tools

To pick shadow colours, use Color Picker. To style a complete button, try CSS Button Generator, and to compress the finished stylesheet, CSS Minifier.

Sticky headers

A header that stays at the top of the screen while content scrolls beneath it benefits from a faint shadow, but only once scrolling has started. Adding a class when the page is scrolled, and giving that class a level 1 or 2 shadow, shows that content is passing underneath. At the very top of the page the header sits flat and clean.

Borders without layout changes

A shadow with no offset, no blur and a one-pixel spread, 0 0 0 1px, draws a line around an element exactly like a border, but without changing its size. That makes it ideal for hover outlines on cards and images, because adding a real border on hover would nudge the layout by a pixel and make neighbouring content jump.

Printing

Browsers may leave shadows out when pages are printed, especially when background graphics are switched off in the print settings. Cards that rely only on shadows to separate them from the page then merge together on paper. A print stylesheet that adds light borders keeps printed receipts, reports and tickets readable.

Naming shadow levels

Name shadow tokens by level or purpose, such as shadow-card and shadow-dialog, and document when each should be used. When a new component arrives, designers and developers choose from the list instead of inventing yet another shadow, which is how consistency survives a growing product.

Privacy

Shadows are designed and previewed in your browser. Nothing is uploaded or stored.

Frequently asked questions

What do the box-shadow values mean?

In order: horizontal offset, vertical offset, blur radius, spread radius and color, with the optional inset keyword first. Positive offsets move the shadow right and down, blur softens the edge, and spread grows or shrinks the shadow before it is blurred.

How do I make a soft, realistic shadow?

Use a low opacity, a large blur and a small negative spread, with the shadow offset downwards, for example 0 10px 30px -5px at 25 percent opacity. Layering two or three such shadows of different sizes looks even more natural.

What is an inset shadow?

The inset keyword draws the shadow inside the element's border instead of outside, so the element looks pressed in or recessed. It is often used for input fields, toggles and buttons in their active state.

Can I use multiple shadows on one element?

Yes. box-shadow accepts a comma-separated list, and the first shadow in the list is drawn on top. This generator lets you add as many layers as you need and writes them in the right order.

Do box shadows slow pages down?

Static shadows are cheap. Animating large blurred shadows can stutter on low-end phones; to animate elevation, fade the opacity of a pseudo-element that carries the shadow instead of changing the shadow itself.

Do I need vendor prefixes?

No. box-shadow has been supported without prefixes by every major browser for more than a decade, so the plain property shown here is all you need in your stylesheet.

How do I use the Tailwind output?

Paste the class into your markup. Tailwind's arbitrary value syntax uses underscores in place of spaces, so the generated class works in Tailwind CSS 3 and later without any change to your configuration.

What is the difference between blur and spread?

Blur controls how soft the edge of the shadow is, from a hard line at zero to a wide fade. Spread changes the size of the shadow before blurring: positive values make it larger than the element, negative values smaller.