CSS Box Shadow / Gradient Generator

A good card on a web page usually comes down to two pieces of CSS: the shadow that lifts it off the background, and the gradient that fills it. Writing either one by hand means guessing numbers, saving, refreshing, and guessing again. This generator replaces the guessing with sliders — you drag, the preview moves, and the finished CSS sits in a box underneath, ready to copy.

The two jobs live in two tabs on this one page. In Box shadow mode you set the horizontal and vertical offset, blur, spread, colour and opacity, with an inset switch for inner shadows, and watch the result land on a sample card. In Gradient mode you pick linear or radial, set the angle, arrange up to three colour stops, and see the blend on a preview strip and on a sample card.

That shared sample card is the quiet point of the page. The card previewing your gradient is already wearing the shadow you built in the other tab — because that’s how the two will actually meet in your stylesheet. You judge the pairing here, once, instead of pasting two snippets into a page and discovering they fight each other.

A designer's monitor showing an indigo-to-pink gradient, with a fan of colour swatches and a graphics tablet on the desk, while making CSS with a box shadow and gradient generator

CSS Box Shadow / Gradient Generator

Design a card’s shadow and its gradient background side by side — sliders and colour pickers in, ready-to-paste CSS out, with the two previews sharing one sample card so you can judge the combination.

Sample card
Your shadow lands on this card as you drag — judge it here, not in your stylesheet.
Preview
Start from a recipe:

The colour is written as rgba() — your picked colour plus the opacity as its alpha — because a shadow colour is almost never fully solid. Negative spread tucks a soft shadow in under the card instead of letting it balloon; that one trick is behind most “premium” card shadows you’ll see. This tool builds one shadow at a time, which covers the great majority of card, button and modal styling; if you ever need layered shadows, generate each layer here and join the values with commas in a single box-shadow declaration.

How it works

A CSS box-shadow is four lengths and a colour, in a fixed order: horizontal offset, vertical offset, blur radius, spread radius, then the colour — with the word inset in front when the shadow belongs inside the element. This tool writes the colour as rgba(), combining the colour you pick with the opacity slider as its alpha value, because a shadow at full strength is almost never what a design wants. A small negative spread tucks a soft shadow in under the card rather than letting it balloon outwards — it's the single setting behind most of the soft, expensive-looking card shadows you'll see on the web, and the Soft card recipe below uses exactly that.

Gradients are built the way CSS expects them. A linear gradient runs along an angle — 0deg points up, 90deg points right, and 135deg runs from the top-left corner to the bottom-right, the diagonal most hero sections settle on. A radial gradient blooms out from the centre in a circle instead. Each colour stop is a colour plus a position: where along the blend that colour is at full strength. The middle stop here has a position slider of its own and can be switched off entirely, because where a colour sits changes a gradient as much as the colour does — slide it towards one end and a smooth blend becomes a wash with a band.

Three recipes per mode give you a starting point, and they work the way recipes should: clicking one loads its values into the sliders, colour pickers and switches, so you can see exactly what makes it look that way and pull it apart from there. The tool builds one shadow at a time — enough for the great majority of cards, buttons and modals. If you ever need layered shadows, generate each layer here and join the values with commas in a single declaration; the first shadow in the list paints on top.

How to use it

  1. Start in Box shadow mode — or click a recipe (Soft card, Floating, Neon edge) to load a known-good starting point into the controls.
  2. Drag the offset sliders to place the shadow, blur to soften it, and spread to grow or tuck it. Set the colour and opacity, and tick Inset if the shadow belongs inside the element.
  3. Copy the box-shadow declaration from the output box into your stylesheet.
  4. Switch to Gradient mode and choose Linear or Radial. For a linear gradient, set the angle; then set your colours and their positions, switching the middle colour on only if the blend needs it.
  5. Check the sample card — it's wearing your shadow over your gradient. Adjust until the pairing looks right, not just each half on its own.
  6. Copy the background declaration and paste it into the same rule as your shadow.

A worked example

Click Soft card in Box shadow mode and every control is set for you: horizontal offset 0, vertical offset 10, blur 20, spread −5, colour black (#000000) at 25% opacity, inset off. The output box reads:

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

Read it left to right and it's the recipe in one line: no sideways shift, dropped 10 pixels down, softened by a 20-pixel blur, pulled in by a 5-pixel negative spread, in black at quarter strength. Tick Inset with the same values and the declaration becomes box-shadow: inset 0px 10px 20px -5px rgba(0, 0, 0, 0.25); — same shadow, painted inside the card instead of behind it.

Now switch to Gradient mode and click Sunset: linear, angle 135deg, three stops — #f59e0b at 0%, #ef4444 at 55%, #8b5cf6 at 100%. The output:

background: linear-gradient(135deg, #f59e0b 0%, #ef4444 55%, #8b5cf6 100%);

The 55% middle stop is doing quiet work there — the red gets slightly more than half the run, so the blend leans warm. Switch the middle colour off in the Ocean recipe instead (sky #0ea5e9 into blue #2563eb at 90deg) and the output drops to two stops: background: linear-gradient(90deg, #0ea5e9 0%, #2563eb 100%);. Every string on this page was produced by the tool's own controls — set them, and the output follows character for character.

Who it is for

Front-end developers styling cards, buttons and modals who'd rather drag than guess; designers handing values to a developer and wanting the exact declaration, not a screenshot; site owners and bloggers customising a theme's CSS one rule at a time; and students learning what each box-shadow number actually does — which you learn fastest by dragging one slider at a time and watching a real card change.

Why use this tool

  • Shadow and gradient on one page — the two halves of a card's styling, designed together, with the gradient's sample card wearing your shadow so the pairing is judged before it's pasted.
  • Recipes that set the controls — Soft card, Floating, Neon edge, Sunset, Ocean and Mono fade load their values into the sliders and pickers, so a preset is a starting point you can inspect and adjust, not a string you copy blind.
  • Positions, not just colours — the middle gradient stop has its own position slider and an off switch, so two-colour washes and three-colour blends both come out of the same controls.
  • Honest, standard output — plain box-shadow and background declarations in the syntax every modern browser reads, written as rgba() and lowercase hex, with no prefixes, no framework classes and nothing added.

FAQ

What order do the box-shadow values go in?

Horizontal offset, vertical offset, blur radius, spread radius, then the colour — with inset first if the shadow is inside the element. Only the two offsets are required; the rest have sensible defaults. This tool always writes the full form, so the declaration you copy shows every value you're actually using.

Why does the shadow colour come out as rgba() instead of a hex code?

Because opacity is part of the design. A hex colour is fully solid, and a fully solid shadow looks like a grey slab behind the card. Writing the colour as rgba() lets the opacity slider become the alpha value — black at 25% (rgba(0, 0, 0, 0.25)) is the soft grey most card shadows are really made of, and it adapts to whatever background the card sits on.

What does negative spread do?

It shrinks the shadow's shape before the blur is applied. A small negative spread on a soft, blurred shadow tucks it in under the element, so the visible shadow hugs the card instead of spreading wider than it. It's the setting behind the Soft card recipe here — and the reason a shadow can look "premium" at the same blur where another looks like a fog.

What's the difference between linear and radial gradients?

A linear gradient blends along a straight line at the angle you set — corner to corner, say. A radial gradient blends outward from the centre in a circle, like a glow. Linear suits page sections, buttons and cards; radial suits highlights, glows and spotlight effects. This tool builds both from the same three colour stops.

Can I make a shadow with more than one layer?

This tool builds one shadow at a time, which covers most card, button and modal styling. For a layered effect, generate each shadow here separately and join the values with commas in one box-shadow declaration — CSS paints the first one on top. A tight, darker shadow over a wide, faint one is the usual pairing.

Is anything I design uploaded or saved?

No. The previews and the CSS are generated locally in your browser as you drag. Nothing is sent to a server, stored, or tracked — close the tab and the design is gone, so copy the declarations you want to keep.

What order do the box-shadow values go in?

Horizontal offset, vertical offset, blur radius, spread radius, then the colour — with inset first if the shadow is inside the element. Only the two offsets are required; the rest have sensible defaults. This tool always writes the full form, so the declaration you copy shows every value you're actually using.

Why does the shadow colour come out as rgba() instead of a hex code?

Because opacity is part of the design. A hex colour is fully solid, and a fully solid shadow looks like a grey slab behind the card. Writing the colour as rgba() lets the opacity slider become the alpha value — black at 25% (rgba(0, 0, 0, 0.25)) is the soft grey most card shadows are really made of, and it adapts to whatever background the card sits on.

What does negative spread do?

It shrinks the shadow's shape before the blur is applied. A small negative spread on a soft, blurred shadow tucks it in under the element, so the visible shadow hugs the card instead of spreading wider than it. It's the setting behind the Soft card recipe here — and the reason a shadow can look "premium" at the same blur where another looks like a fog.

What's the difference between linear and radial gradients?

A linear gradient blends along a straight line at the angle you set — corner to corner, say. A radial gradient blends outward from the centre in a circle, like a glow. Linear suits page sections, buttons and cards; radial suits highlights, glows and spotlight effects. This tool builds both from the same three colour stops.

Can I make a shadow with more than one layer?

This tool builds one shadow at a time, which covers most card, button and modal styling. For a layered effect, generate each shadow here separately and join the values with commas in one box-shadow declaration — CSS paints the first one on top. A tight, darker shadow over a wide, faint one is the usual pairing.

Is anything I design uploaded or saved?

No. The previews and the CSS are generated locally in your browser as you drag. Nothing is sent to a server, stored, or tracked — close the tab and the design is gone, so copy the declarations you want to keep.

Related free tools