CSS Box Shadow Generator

A free tool by DeepRit, a Google Ads agency that does PPC and nothing else. We build and run Google Ads accounts so every click is accounted for. Book a free audit call

Free CSS box shadow generator. Adjust offset, blur, spread, color and opacity, add a second layer for realistic depth, preview it and copy the CSS.

Preview
CSS

Free, no sign-up. Runs in your browser: nothing you type is uploaded or saved.

How to use the box shadow generator

  1. Start from a preset: Soft, Medium, Sharp, Floating (two layers) or Inner (inset).
  2. Adjust the sliders: horizontal and vertical offset, blur, spread and opacity.
  3. Pick a shadow color. Black works for most designs; a dark shade of your background color often looks more natural.
  4. Tick Inset for a shadow inside the box, as if it were pressed in.
  5. Keep "Add a soft second layer" ticked for more realistic depth, or untick it for a single shadow.
  6. Copy the CSS from the box below the preview.

The box shadow generator writes standard CSS that works in every modern browser. Nothing is uploaded and there's no sign-up.

What each setting means

A CSS box shadow is written as:

box-shadow: [inset] x-offset y-offset blur spread color;
Setting What it does
Horizontal offset Moves the shadow right (positive) or left (negative).
Vertical offset Moves the shadow down (positive) or up (negative). Most shadows go down, as if lit from above.
Blur How soft the edge is. 0 is a hard edge; larger values spread the shadow wider and fainter.
Spread Makes the shadow bigger (positive) or smaller (negative) than the box before blurring.
Color and opacity The shadow's color. The box shadow generator writes it as rgba() so the opacity is built in.
Inset Draws the shadow inside the box instead of outside.

A negative spread with a large blur is a useful trick: it keeps the shadow tucked under the box so it only shows at the bottom, which looks like the element is floating just above the page.

Why two layers look better

In real life, an object casts two kinds of shadow: a soft, wide one from the general light around it, and a small, darker one right where it's closest to the surface. A single CSS shadow can only be one or the other, which is why single shadows often look either flat or muddy.

When "Add a soft second layer" is ticked, the generator adds a second, tighter shadow: a quarter of the offset and blur, at slightly less opacity. The result is a shadow with a crisp contact edge and a soft spread:

box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.25),
    0 5px 10px 0 rgba(0, 0, 0, 0.2);

Layered shadows like this are what most modern design systems use for cards, menus and dialogs.

The presets

  • Soft: a gentle shadow for cards and panels. Barely there, but enough to separate the card from the page.
  • Medium: more lift, for dropdown menus and popovers that sit above other content.
  • Sharp: a solid, offset shadow with no blur, a bold, graphic look common in "neo-brutalist" designs.
  • Floating: a large, soft, two-layer shadow for modals, hero images and featured cards.
  • Inner: an inset shadow that makes the element look pressed into the page, used for input fields and pressed buttons.

Choosing shadow colors

Pure black at high opacity tends to look dirty, especially on colored backgrounds. Better options:

  • Black at low opacity, 10% to 25%, for white and light grey backgrounds.
  • A darker shade of the background color. On a cream page, a dark brown shadow looks warmer and more natural than grey. The color shades generator gives you darker versions of any color.
  • A tint of the element's color for "glow" effects, such as a blue shadow under a blue button.

To use a brand color, copy its HEX code into the color picker. If you have only RGB values, the HEX to RGB converter converts between the two.

Shadows for elevation

Design systems often use shadows to show how "high" an element is: the higher it is, the bigger and softer its shadow. A simple scale:

  1. Resting cards: soft, small shadow (around 2 to 4 px offset).
  2. Hovered cards and buttons: a little more offset and blur, to suggest the element has lifted towards the pointer.
  3. Dropdowns and menus: medium shadow (8 to 16 px).
  4. Dialogs and modals: large, layered shadow (20 px or more), so they clearly sit above everything else.

Using a consistent scale makes an interface easier to understand at a glance. Save each level as a CSS custom property, such as --shadow-1, and reuse it.

Performance tips

Box shadows are drawn by the browser and need no image files, so they're light. Two cautions:

  • Avoid animating box-shadow directly on many elements; it makes the browser repaint on every frame. For hover effects, put the larger shadow on a pseudo-element and animate its opacity instead.
  • Very large blurs on many elements can slow down scrolling on older phones. Keep blurs reasonable on long lists.

If your stylesheet grows, the CSS minifier removes the spaces and line breaks for production.

Box shadows with gradients and sizes

Shadows often go with gradients and rounded corners: a slight top-to-bottom gradient and a soft shadow make a button look tactile. The CSS gradient generator writes matching gradient CSS. If you're working in rem units, the px to rem converter converts offsets and blurs.

Accessibility

Shadows help people see where one element ends and the next begins, but they shouldn't be the only clue. Users with low vision, or anyone on a screen in bright sunlight, may not see a faint shadow at all. For important boundaries, such as the edges of form fields and buttons, add a border with enough contrast too. The color contrast checker checks that borders meet the WCAG 3:1 guideline for interface elements.

box-shadow versus drop-shadow

box-shadow follows the rectangle of an element, including its rounded corners. If you need a shadow that follows the shape of a transparent PNG or an SVG icon, use filter: drop-shadow(x y blur color) instead. It has no spread value and no inset option, but it traces the visible outline.

Shadows in dark mode

Shadows are hard to see on dark backgrounds, because there's little room to get darker. In dark themes, designers usually:

  • Make surfaces lighter as they rise, instead of relying on shadows: a raised card is a slightly lighter grey than the page.
  • Use stronger, darker shadows with higher opacity (40% to 60%) if shadows are still wanted.
  • Add a subtle light border, such as a 1 px line at 8% white, so edges stay visible.

If your site has both light and dark themes, store each shadow as a CSS custom property and redefine it for the dark theme, so components don't need to change.

Common box shadow recipes

  • Subtle card: 0 1px 3px rgba(0, 0, 0, 0.12) with a second layer 0 1px 2px rgba(0, 0, 0, 0.08).
  • Focus ring for accessible keyboard focus: 0 0 0 3px rgba(59, 130, 246, 0.5): no offset, no blur, just spread.
  • Bottom-only shadow: 0 8px 6px -6px rgba(0, 0, 0, 0.3): the negative spread hides it on the sides.
  • Pressed button: inset 0 2px 4px rgba(0, 0, 0, 0.2).

Each of these can be recreated with the sliders in the box shadow generator, then tuned to your colors.

A worked example

A designer is styling product cards for an online bakery. The page background is cream (#f4e9dc), and the cards are white with rounded corners. A plain black shadow looks grey and harsh on the cream.

She opens the box shadow generator, starts from Soft, and changes the color to a dark brown, #3b2a1e. She sets vertical offset to 6, blur to 18, spread to −4 and opacity to 18%, and leaves the second layer on. The preview shows a warm, gentle lift that matches the page.

For the hover state, she makes a stronger version: offset 14, blur 32, spread −8, opacity 22%. She copies both and saves them as --shadow-card and --shadow-card-hover. The cards look like they belong on the page instead of floating in grey fog.

Need more customers from Google?

This tool is free and runs in your browser. If your business also needs more leads or sales, Google Ads is where people search with their wallet out. DeepRit is a Google Ads agency that does PPC and nothing else: we build the campaigns, block the searches that waste money, write the ads, set up conversion tracking and send you a short report every week. Request a free PPC audit and we will show you, in dollars, what we would fix first.

Frequently asked questions

How do I add a shadow in CSS?

Use the box-shadow property, such as box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);. This box shadow generator lets you adjust each value with sliders and copy the finished CSS.

What does spread do in box-shadow?

Spread makes the shadow larger (positive) or smaller (negative) than the element before the blur is applied. A negative spread with a big blur keeps the shadow under the element.

How do I make a shadow inside an element?

Add the inset keyword. In the box shadow generator, tick Inset, or choose the Inner preset.

Can I have more than one box shadow?

Yes. Separate shadows with commas. The generator's "second layer" option adds a tighter shadow under the main one for more realistic depth.

Is this box shadow generator free?

Yes. It's free with no sign-up and no limits, and the CSS is yours to use.

Why does my shadow look grey and dirty?

Usually the opacity is too high or the color is pure black on a colored background. Lower the opacity to 10% to 25%, or use a dark shade of the background color.

Free PPC audit

See where your ad budget leaks.

We look at your Google Ads account before the call, then walk you through what we'd fix first, in dollars. No obligation, no hard sell.

Book a free audit call 30-minute call · Free · The audit is yours to keep