A box shadow css generator earns its place when a card or button needs to feel raised without looking pasted on. The short answer is to stack two soft, low-opacity layers, tint them toward the surface color, and judge the result on the real background. Below I use the 66Colorful CSS Box Shadow Generator to build one, then explain each value so you can adjust it by eye instead of copying numbers blindly.
The tool offers presets, editable layers, a light and dark background checker, and CSS, Tailwind CSS and SCSS output. It also has limits that matter: a preview cannot certify accessibility in your finished interface, and how natural a shadow looks depends on the colors around it and the size of the component.
Table of Contents

How do you build a card shadow in a box shadow css generator?
Take a concrete task: a white card with a 16px corner radius sitting on a pale page. In the 66Colorful tool, the steps look like this.
- Pick the Layered preset under Shadow presets. It combines a small, faint layer (0 1px 3px at 12% opacity) with a larger, softer one (0 8px 24px -4px at 15%).
- Set Element color and Corner radius to match your component, then flip the preview between the Checker, Light and Dark backgrounds.
- Click one row at a time in CSS Shadow Layers and adjust X offset, Y offset, Blur radius, Spread and Opacity. Editing one layer at a time shows what each contributes.
- Change the row color from black to a tint of your surface color (the next sections cover why).
- Choose CSS, Tailwind CSS or SCSS under CSS Shadow Code and use the copy button.
The tool allows up to 8 layers, though you will rarely need that many. The top row paints on top, which matches CSS, where the first shadow in a comma-separated list sits above the ones after it.
Treat the preview as a stand-in. It shows the shadow on a plain element, not beside your headings, photos and neighboring cards, so paste the code into the real page and look again before you commit.

What do offset, blur, spread and color do in box-shadow?
The value order is box-shadow: x-offset y-offset blur spread color, with an optional inset keyword at the start. The MDN box-shadow reference documents each part, and the CSS Backgrounds and Borders Module Level 3 defines how shadows are drawn.
- Offset: a positive X moves the shadow right, and a positive Y moves it down. A small positive Y suggests light from above. The tool accepts -100 to 100 px for both.
- Blur: a larger radius softens the edge, and 0 gives a hard edge. The tool range is 0 to 150 px.
- Spread: this grows or shrinks the shadow before blur is applied. A negative spread contracts it, which stops a wide blur from spilling past the sides. The range is -50 to 50 px.
- Color and opacity: alpha does most of the work in making a shadow look natural. The tool’s own tips put 8% to 25% as a range that usually looks more natural than 50% or more.
A shadow follows the element’s rounded corners and does not change layout, so it can overlap neighbors without pushing them. The default layer in the tool, 0 10px 25px -5px at 25% black, is a useful reference: no sideways shift, 10px down, generous blur, and a slight negative spread.

Single heavy shadow or layered shadows: which should you choose?
For most cards and buttons, choose two layered shadows. A single heavy shadow is a blunt tool: to make it visible you raise opacity or blur, and both push it toward looking smudged. Light in real scenes gives a tight contact shadow plus a wide ambient one, and two layers imitate that cheaply.
| Criterion | One heavy shadow | Two layers | Three or more layers |
|---|---|---|---|
| Edge definition | Blurry, or hard if blur is low | Small layer defines the near edge | Fine control of the edge |
| Sense of depth | Flat and uniform | Contact plus separation | Can model several elevations |
| Risk of looking harsh | Higher, since opacity carries everything | Lower, since each layer stays faint | Lower per layer, but easy to overdo |
| Editing effort | Minimal | Moderate | Higher, and harder to maintain |
| Typical fit | Hard-offset or glow styles | Cards, buttons, menus | Large floating panels or modals |
When to choose which
Pick one layer when the style is deliberately graphic, such as a sharp offset block or a glow. Start with two layers for everyday interface elements. Add a third only when it does a distinct job, for example a very wide, faint layer under a modal. Two or three layers is a workflow habit, not a CSS limit or a researched ideal, so let the preview decide.
How do you tint a shadow instead of using pure black?
Pure black is not wrong, but a low-opacity dark color pulled toward the surface hue often blends better. Here is a two-layer starting example for a card on a cool, pale page:
.card {
box-shadow:
0 1px 3px rgb(28 45 69 / 0.12),
0 8px 24px -4px rgb(28 45 69 / 0.15);
}
The tint is #1C2D45, a dark desaturated blue. The compact first layer defines the near edge, and the wider, fainter second layer suggests separation. These numbers are a starting example, not a measured optimum, so adjust them against your actual surface and corner radius in the preview. The tool’s example output uses the comma-separated rgba() form, which is equivalent to the space-separated syntax above.
Choose the tint by looking at the background behind the card. A warm cream page may suit a dark brown, and a cool gray page may suit a slate. If you need a darker version of a surface color to start from, the Tint Shade Generator can produce tints and shades of a base color. Treat this as design guidance, not a standards requirement, and compare against plain black before you decide.
Can a shadow be the only cue for a button or card edge?
It should not be the only cue where a user must identify a control. WCAG 2.2 Success Criterion 1.4.11 Non-text Contrast, at Level AA, asks for a 3:1 contrast ratio for visual information needed to identify a component or its state. The Understanding document for 1.4.11 does not impose a blanket 3:1 rule on decorative card shadows, and it notes that button context or text styling can also identify a button.
In practice, I split the question in three:
- Decorative cards: if headings and spacing already group the content, a faint shadow is styling and not a requirement.
- Buttons and inputs: give the control a fill, border or clear label, and measure that edge against the adjacent color with the Contrast Checker. A blurred shadow has no single measurable color, so it makes a poor thing to test.
- Keyboard focus: use a separate focus indicator instead of borrowing the resting shadow. Focus Visible (2.4.7) is Level AA, while Focus Appearance (2.4.13) in WCAG 2.2 is Level AAA. My article on a two-color focus indicator shows a pattern that stays visible on varied backgrounds.
Shadows can also be removed by forced-colors modes, so an interface that depends on them may lose its edges for those users. If the button label or icon sits on a colored fill, the piece on thin icons on colored buttons covers that contrast question. One passing pair never makes a whole interface compliant, so test each state.
Why do shadows look harsh, and what changes in dark mode?
A harsh shadow usually traces back to one of four causes. Check them in this order in the preview.
- Opacity is too high. Pull each layer down toward the 8% to 25% range.
- Tight blur with a large spread. A crisp, wide band reads as an outline, not depth. Raise blur or make spread negative.
- An oversized offset. A 40px Y offset on a small button detaches the shadow from it. Scale offset with the element size.
- A clashing hue. Neutral black on a tinted surface can look dirty. Try a low-opacity color tinted toward the surface.
Adding another layer rarely fixes any of these, so reduce first and add later.
What changes in dark mode?
A dark shadow on a dark surface may add little visible separation, and raising its opacity mostly makes the page muddier. Switch the tool’s preview to Dark and judge the card there. If it merges into the page, try a slightly lighter surface, a subtle border, or both, and keep a softer shadow as a supporting detail. The prefers-color-scheme media feature lets you serve different shadow values per mode, and the generator cannot know which mode your visitor uses, so define both sets deliberately.
How do the Glassmorphism and Neumorphism generators pair with shadows?
The 66Colorful tools directory describes the Glassmorphism Generator as controlling transparency, border and shadow, and the Neumorphism Generator as building soft surfaces from a base color with contrast checks. Both effects lean on shadows, so a sensible order is to settle the basic elevation first and then layer the effect on top.
- Build the baseline card shadow in the shadow tool until the card sits comfortably on its background.
- For a translucent panel, open the Glassmorphism Generator and adjust transparency and border. Its shadow should usually be softer than your solid card shadow, since the blurred backdrop already adds depth.
- For a soft, extruded look, open the Neumorphism Generator and start from the base color of the surface it will sit on.
- Place the combined card in its real context and compare it with the plain version.
Avoid stacking two full shadow systems on one element, which is a common route to a heavy, cluttered look. Soft, low-contrast surfaces in particular can lose their edges, and neither effect replaces a discernible control or a visible focus state. Keep a label, border or fill that identifies interactive parts independently of the effect.
Box shadow css generator output: when should it become a design token?
Copy the code straight into a component while you experiment. Once the same shadow appears on several cards or buttons, move it into a semantic custom property such as –shadow-card and define separate light and dark values where needed:
:root {
--shadow-card: 0 1px 3px rgb(28 45 69 / 0.12), 0 8px 24px -4px rgb(28 45 69 / 0.15);
--border-card: #D3DAE4;
}
@media (prefers-color-scheme: dark) {
:root {
--shadow-card: 0 1px 3px rgb(0 0 0 / 0.4), 0 8px 24px -4px rgb(0 0 0 / 0.5);
--border-card: #2B3647;
}
}
.card {
border: 1px solid var(--border-card);
box-shadow: var(--shadow-card);
}
These dark values are a starting point to check in the Dark preview, not tested answers. Naming the token by role means components never hard-code numbers, so one edit updates every card.
For the color side of the system, the CSS Variable Theme Generator exports light and dark color tokens, and the CSS Theme Builder produces a set from one brand color. Both handle color roles, so add shadow variables by hand alongside them. My article on brand color design tokens explains how to name roles so they scale.
Frequently asked questions
What is the difference between inset and outer box shadows?
An outer shadow is drawn outside the element and suggests it is raised. An inset shadow is drawn inside the border edge and suggests a pressed or recessed surface, as in the tool’s Pressed preset. Tick Inset (inner shadow) on a layer to switch it.
Why does my box shadow look harsh?
The usual causes are high opacity, a tight blur with a large spread, an oversized offset, or a hue that clashes with the surface. Adjust context first, such as lowering opacity or softening blur, instead of adding another layer.
How many shadow layers are enough?
Two is a good default for cards and buttons: one compact layer for the near edge and one wide, faint layer for separation. Add a third only if it serves a distinct purpose. This is a workflow heuristic, not a CSS limit.
Should a box shadow always be pure black?
No rule requires it. A low-opacity dark color tinted toward the surface often blends better, but black can work on neutral backgrounds. Compare both in the preview on your real background.
Does a card shadow need to meet WCAG contrast?
Not as a blanket rule. Success Criterion 1.4.11 requires 3:1 for visual information needed to identify components and states. A purely decorative shadow is outside that, but a border or fill that identifies a control is not.
Can I reuse the same shadow in dark mode?
You can, but dark shadows on dark surfaces often give little separation. Check the Dark preview and consider a lighter surface step or a subtle border, with separate custom property values for each mode.
Can a CSS box-shadow generator export Tailwind or SCSS?
The 66Colorful tool offers CSS, Tailwind CSS and SCSS output under CSS Shadow Code, with copy buttons for CSS and Tailwind. Check the exported value in your own project, since your Tailwind setup may differ.
Next steps
A good box shadow css generator workflow is short: start from the Layered preset, tint both layers toward the surface, keep opacity low, and inspect the Light and Dark previews. Then confirm that the edge of every button, input and focus state is carried by something other than the shadow. Once a shadow repeats, store it as a token with separate light and dark values, and pick one existing card in your project to convert this week.
Related tools & resources on 66Colorful:
- Css Shadow Generator
- Glassmorphism Generator
- Neumorphism Generator
- Css Variable Theme Generator
- Contrast Checker
- Brand Color Design Tokens Css Variables