CSS Box-Shadow Generator
This free CSS box-shadow generator builds smooth, layered shadows tinted with your background color, and previews them on a light and a dark page side by side. It adds a dark mode version, a hover lift that animates without repainting, an sm to xl elevation scale, and CSS or Tailwind output ready to paste.
Shadow color #201F1D, a darker shade of the page.
Preview surface
Hover or tap a card to see the lift.
- Shadows fade on dark pages, so the card rises insteadA shadow can't darken a near-black page much. The dark version lightens the card to #1C1F23 (1.14:1 against the page), adds a 1 px highlight edge and strengthens the shadow.
- Card edge contrast 1.12:1Fine for a card. If this is a button or an input, WCAG 1.4.11 asks for a 3:1 boundary: add a border or a stronger edge.
- Hover stays smoothIt fades a ready-made shadow and moves the card, so the browser never repaints the shadow while animating.
Your shadow
.card {
border-radius: 16px;
box-shadow: 0 1.5px 3px 0 rgb(32 31 29 / 0.07), 0 3px 6px 0 rgb(32 31 29 / 0.07), 0 6px 12px 0 rgb(32 31 29 / 0.07), 0 12px 24px 0 rgb(32 31 29 / 0.07), 0 24px 48px 0 rgb(32 31 29 / 0.07);
position: relative;
transition: translate 0.2s ease;
}
/* The hover shadow already sits on an invisible ::after; hovering only
fades it in. Animating box-shadow itself repaints on every frame. */
.card::after {
content: "";
position: absolute;
inset: 0;
border-radius: inherit;
box-shadow: 0 3px 6px 0 rgb(32 31 29 / 0.07), 0 6px 12px 0 rgb(32 31 29 / 0.07), 0 12px 24px 0 rgb(32 31 29 / 0.07), 0 24px 48px 0 rgb(32 31 29 / 0.07), 0 48px 96px 0 rgb(32 31 29 / 0.07);
opacity: 0;
transition: opacity 0.2s ease;
pointer-events: none;
}
.card:hover {
translate: 0 -2px;
}
.card:hover::after {
opacity: 1;
}
@media (prefers-color-scheme: dark) {
.card {
background-color: #1C1F23;
box-shadow: 0 1.5px 3px 0 rgb(0 0 0 / 0.2), 0 3px 6px 0 rgb(0 0 0 / 0.2), 0 6px 12px 0 rgb(0 0 0 / 0.2), 0 12px 24px 0 rgb(0 0 0 / 0.2), 0 24px 48px 0 rgb(0 0 0 / 0.2), inset 0 0 0 1px rgb(255 255 255 / 0.06);
}
.card::after {
box-shadow: 0 3px 6px 0 rgb(0 0 0 / 0.2), 0 6px 12px 0 rgb(0 0 0 / 0.2), 0 12px 24px 0 rgb(0 0 0 / 0.2), 0 24px 48px 0 rgb(0 0 0 / 0.2), 0 48px 96px 0 rgb(0 0 0 / 0.2), inset 0 0 0 1px rgb(255 255 255 / 0.06);
}
}
What does this box-shadow generator do?
It builds CSS box shadows that look good and keep working where most shadows fail: on dark pages, on hover, and across a whole design system.
- Smooth mode. Set the elevation and the number of layers, and it stacks shadows in a geometric series, short and sharp near the element, long and soft further out. That is how real light falls off.
- Shadows tinted by the page. The shadow color is a darker shade of your background instead of flat black, which avoids the grey, dirty look on colored pages.
- Light and dark previews side by side, so you see the problem before your users do.
- A dark mode version that lifts the card with a lighter surface and a hairline edge, because shadows barely show on near-black pages.
- A hover lift that doesn't repaint, using the pseudo-element pattern explained below.
- An elevation scale from sm to xl, as CSS variables or a Tailwind v4
@themeblock. - Layers mode, presets and paste: edit every layer by hand, start from Soft card, Floating, Pressed, Glow, Neumorphic or Retro, or paste a shadow you already use.
How do you create a box shadow?
- Pick a preset, or stay in Smooth and set Elevation, Layers, Softness, Opacity per layer and Light direction.
- Set the preview colors to match your site: page, card and dark page.
- Switch to Layers to fine-tune any layer, or paste an existing value into Paste a box-shadow to edit it.
- Keep Lift on hover and Add a dark mode version on if you want them in the code.
- Copy the CSS, a Tailwind class, the Elevation scale or a drop-shadow filter.
Why do shadows disappear in dark mode?
A shadow works by darkening what is behind it, and a near-black page has almost nowhere darker to go. The same shadow that reads clearly on white can drop close to 1:1 contrast on a dark background.
| Background | What shows height | What this tool outputs |
|---|---|---|
| Light page | The shadow | Your layered shadow |
| Dark page | A slightly lighter card surface | A raised surface color, a 1 px highlight edge and a stronger shadow, inside @media (prefers-color-scheme: dark) |
The raised surface follows the same idea as Material Design's dark theme: the higher the element, the lighter its surface.
How do you animate a box shadow smoothly?
Don't transition box-shadow itself: the browser has to repaint the blur on every frame, which stutters on phones. Draw the hover shadow on an ::after pseudo-element with opacity: 0, fade it in on hover, and lift the card with translate. Opacity and translate are handled by the compositor and stay smooth. The generated CSS uses exactly this pattern, and the preview runs the same code.
What this generator does not do
- It doesn't shadow a shape, only the box.
box-shadowfollows the element's rectangle and border radius. For a transparent PNG, an SVG icon or text, use the drop-shadow output, which follows the visible shape but has no spread and no inset. - It doesn't choose your dark theme colors. The raised surface is a starting point computed from your dark page color; your design system may already define one.
- It doesn't read em or rem values when you paste. Pasted shadows need pixel values, which is what almost every shadow uses.
- Neumorphism is not made accessible by the tool. It warns you: a card the same color as the page relies on the shadow alone for its edge, below the 3:1 that WCAG 1.4.11 asks of buttons and inputs.
Is it private?
Yes. Everything runs in your browser, and nothing you type or paste is sent anywhere.
Frequently asked questions
How do I make a CSS box shadow look realistic?
Stack several shadows instead of one. A short, sharp layer close to the element and longer, softer layers further out mimic how real light falls off. Keep every layer lit from the same direction, and tint the shadow with a darker shade of the background instead of pure black. The Smooth mode builds that for you.
Why is my box shadow invisible in dark mode?
A shadow darkens the page, and a near-black page cannot get much darker, so even a strong shadow barely shows. Dark interfaces show height with lighter surfaces instead. The dark mode version here lightens the card slightly, adds a faint one pixel highlight edge and strengthens the shadow, all inside a prefers-color-scheme block.
How do I animate a box shadow without lag?
Do not transition box-shadow itself, because the browser repaints the blur on every frame. Put the hover shadow on an ::after pseudo-element with opacity zero, then fade that opacity in on hover and move the card with translate. Opacity and translate run smoothly. The CSS output includes this pattern when Lift on hover is on.
What do the box-shadow values mean?
The values are horizontal offset, vertical offset, blur radius, spread radius and color, with an optional inset keyword first. Offsets move the shadow, blur softens its edge, spread grows or shrinks it before blurring, and inset draws it inside the element. Several shadows can be listed, separated by commas, and the first one sits on top.
What is the difference between box-shadow and drop-shadow?
box-shadow follows the rectangle of the element, rounded by its border-radius. filter: drop-shadow() follows the visible shape, so it hugs a transparent PNG, an SVG icon or text. drop-shadow has no spread and no inset, so the drop-shadow output leaves those layers out and tells you how many it skipped.
How do I use a custom shadow in Tailwind CSS?
Use the Tailwind output. It gives an arbitrary-value class such as shadow-[0_4px_8px_0_rgb(0_0_0/0.1)] with every space already turned into an underscore. For a whole design system, the Elevation scale output writes a Tailwind v4 @theme block, so shadow-sm, shadow-md, shadow-lg and shadow-xl use your shadows.
How do I make an inner shadow in CSS?
Add the inset keyword to a shadow, or pick the Pressed preset. An inset shadow is drawn inside the border instead of outside, which makes a surface look pressed in, like a clicked button or an input field. You can mix inset and outer layers in one box-shadow value, separated by commas.
Is neumorphism accessible?
Often not. Neumorphic cards are the same color as the page and rely on a light and a dark shadow for their edge, which is very low contrast. That is acceptable for decoration, but buttons and inputs need a 3 to 1 boundary under WCAG 1.4.11. The checker flags this when the card and page colors match.
Can I edit a box shadow I already have?
Yes. Paste any box-shadow value, even a whole line starting with box-shadow and ending with a semicolon, and it opens in the Layers editor. It reads pixel values and zero, hex, rgb and rgba colors in any position, inset shadows, and several layers separated by commas.
What is an elevation scale?
It is a small set of shadows for different heights, such as a card, a dropdown and a dialog, drawn from the same light and style. Here each level doubles the height of the one below, from sm to xl, and the result comes out as CSS custom properties or a Tailwind v4 theme.
Related tools
Rate CSS Box-Shadow Generator & help shape it
This tool is free and still growing. Tell us what works, what you would change, and what is missing. Your feedback is what decides what we build next.
Built and tested by the ÆON Toolhub team. Last updated: September 29, 2026. How we test our tools



