Skip to content

Runs entirely in your browser. Nothing you paste leaves this page.

Free / No sign-up

CSS gradient and box-shadow generator.

Build linear, radial and conic gradients with draggable colour stops and OKLab or OKLCH interpolation, or stack box-shadow layers. Copy plain CSS with a fallback, or a Tailwind class.

Generator
Gradient type
Interpolation colour space

Drag stops on the bar or click it to add one.

sRGBOKLCH
Colour stops (2)
  • %
  • %

CSS

background-image: linear-gradient(90deg, #1f5eff 0%, #ffd400 100%);
background-image: linear-gradient(90deg in oklch, #1f5eff 0%, #ffd400 100%);

Tailwind class

bg-[linear-gradient(90deg_in_oklch,#1f5eff_0%,#ffd400_100%)]

Interpolation in OKLab or OKLCH works in Chrome and Edge 111+, Safari 16.2+ and Firefox 127+. The CSS includes an sRGB fallback line for older browsers.

How to use it.

  1. 01

    Pick a preset or drag the stops on the bar. Click the bar to add a stop; select one to change its colour or position.

  2. 02

    Choose linear, radial or conic, the angle or centre, and sRGB, OKLab or OKLCH interpolation.

  3. 03

    Copy the CSS (with an sRGB fallback) or the Tailwind class. Switch to Box shadow to layer shadows the same way.

What it does.

Everything this tool handles, all of it inside your browser tab.

  • Linear, radial and conic gradients
  • Draggable colour stops; click the bar to add one, arrow keys to nudge
  • sRGB, OKLab or OKLCH interpolation, with longer hue for rainbow sweeps
  • Live sRGB vs OKLCH comparison strip
  • CSS output with an automatic sRGB fallback line
  • Tailwind arbitrary-value class for gradients and shadows
  • Box shadow builder with up to six layers, inset and opacity per layer
  • Presets for gradients and shadows, previewed on light and dark
  • Runs entirely in your browser: no sign-up

Worked examples.

  • Blue to yellow without the grey middle

    /* Fallback for browsers without gradient interpolation (pre-2023) */
    background-image: linear-gradient(90deg, #1f5eff 0%, #ffd400 100%);
    background-image: linear-gradient(90deg in oklch, #1f5eff 0%, #ffd400 100%);

    In sRGB the midpoint is grey. In OKLCH the hue travels through green and stays saturated.

  • The same gradient as a Tailwind class

    bg-[linear-gradient(90deg_in_oklch,#1f5eff_0%,#ffd400_100%)]

    Underscores stand in for spaces inside Tailwind arbitrary values.

  • A radial glow

    radial-gradient(circle at 30% 30% in oklab, #ffffff 0%, #7ea6ff 35%, #0b1020 100%)

    Three stops: a white hotspot, a soft blue halo and a near-black edge, positioned towards the top left.

  • A full hue wheel from one colour

    conic-gradient(from 0deg at 50% 50% in oklch longer hue, #ff3b5c 0%, #ff3b5c 100%)

    With longer hue, two identical stops go all the way round the hue circle, giving a colour wheel.

  • A layered, natural box shadow

    box-shadow: 0px 1px 2px 0px rgb(15 23 42 / 0.06), 0px 4px 8px -2px rgb(15 23 42 / 0.08), 0px 24px 48px -12px rgb(15 23 42 / 0.22);
    
    shadow-[0px_1px_2px_0px_rgb(15_23_42/0.06),0px_4px_8px_-2px_rgb(15_23_42/0.08),0px_24px_48px_-12px_rgb(15_23_42/0.22)]

    A tight contact shadow, a mid shadow and a wide soft one, tinted slate rather than black.

What this generator makes

Three gradient types, each with any number of colour stops: linear gradients along an angle, radial gradients from a centre point as a circle or ellipse, and conic gradients that sweep around a centre. Stops are dragged on the bar, moved with the arrow keys (Shift for steps of 10) or typed as exact percentages.

The output is a background-image declaration ready to paste, plus a Tailwind arbitrary-value class. A second tab builds layered box shadows with offsets, blur, spread, colour, opacity and inset per layer, previewed on light and dark backgrounds.

The output is standard CSS with no runtime library, so it works in any framework. Most email clients ignore gradients, so for email set a solid background-color as well.

Why interpolate in OKLCH or OKLab?

By default, a gradient between hex colours is interpolated in sRGB, mixing the red, green and blue channels in a straight line. Between colours far apart on the colour wheel, such as blue and yellow, the midpoint is a dull grey. OKLab is a perceptual colour space, so steps look even to the eye and the middle stays clean. OKLCH is the same space in polar form (lightness, chroma and hue), so the gradient travels around the hue wheel and keeps its saturation: blue to yellow passes through a bright green instead of grey.

The sRGB and OKLCH strips under the bar show the difference live. Longer hue sends an OKLCH gradient the long way round the wheel, which is how the Hue wheel preset gets a full rainbow from one colour. OKLCH is also how many modern design systems define palettes, because equal steps in lightness look equal.

Support: the in oklch syntax works in Chrome and Edge 111+, Safari 16.2+ and Firefox 127+, so every current major browser has it (Firefox was last, in mid-2024). Older browsers drop a declaration they cannot parse, so the CSS output puts a plain sRGB line first as a fallback.

Gradient syntax, briefly

In linear-gradient, 0deg points up and angles turn clockwise, so 90deg runs left to right and 180deg top to bottom. Radial gradients take a shape and a position: circle at 30% 30% puts a round glow towards the top left. Conic gradients take a start angle and a centre: from 0deg at 50% 50%. The interpolation method sits in the same first argument, for example 90deg in oklch.

Two stops at the same position make a hard edge, which is how CSS stripes and pie charts are drawn. A stop without a position is spaced evenly, but this generator always writes positions so the output is explicit.

Stops, hints, banding and transparency

Stops are a colour plus a position. A stop can carry two positions to make a flat band (red 20% 40%), and a bare percentage between two stops is a colour hint that moves the midpoint of the blend. Both are valid CSS you can add by hand to the copied output.

Banding, visible steps in what should be a smooth gradient, appears in large areas with subtle changes, especially dark ones. Interpolating in OKLab spreads the steps more evenly to the eye; an extra stop to steer the blend, or a faint noise texture on top, hides the rest.

Transparency used to be a trap: fading to the keyword transparent could pass through grey. Current browsers interpolate with premultiplied alpha, so red to transparent stays red as it fades. To be explicit, fade to the same colour with zero alpha, such as rgb(255 0 0 / 0).

Using the output in Tailwind CSS

The Tailwind class is an arbitrary value such as bg-[linear-gradient(90deg_in_oklch,#1f5eff_0%,#ffd400_100%)]. Spaces become underscores, which Tailwind turns back into spaces when it generates the CSS. It works in Tailwind v3 and v4 and suits one-off hero backgrounds. Classes are generated at build time, so paste the full class into your markup rather than assembling it from variables at runtime.

For gradients you reuse, Tailwind v4's own utilities are tidier: bg-linear-90, bg-radial and bg-conic with from-, via- and to- colour stops. Tailwind v4 interpolates them in OKLab by default and accepts modifiers such as bg-linear-to-r/oklch. Teams with a design system usually define brand gradients as tokens instead.

Layered box shadows that look real

A single large shadow tends to look like a smudge. Real objects cast a tight, darker shadow where they touch the surface and a wide, faint one further away, so the Layered preset stacks three shadows of increasing offset and blur with low opacity. Negative spread pulls a large blur in so it does not bleed out to the sides.

Tint shadows with the background's hue instead of pure black, keep the opacity low, and on dark backgrounds rely more on borders and lighter surfaces, because shadows barely show. If you animate elevation, animate the opacity of a pseudo-element that carries the shadow rather than box-shadow itself, which forces a repaint every frame.

Accessibility and performance

Text on a gradient has to pass contrast at its weakest point, not the average. Check the lightest and darkest colour behind the text with our colour contrast checker, or add a solid scrim behind the text. Set a solid background-color under any gradient behind text too, so it stays readable in forced-colours modes and print styles that drop background images. Avoid animating gradients that fill the screen, and respect prefers-reduced-motion if you do animate them.

Gradients are cheap: they render on the GPU, scale to any size and cost no network request, which makes them a good replacement for decorative background images when you are working on Core Web Vitals.

Questions, answered

Something else on your mind? Ask a consultant and get a reply within one business day.

What does in oklch do in a CSS gradient?

It tells the browser to blend the colours in the OKLCH colour space instead of sRGB. Hues travel around the colour wheel and keep their saturation, which avoids the grey middle you get between distant colours.

Which browsers support OKLCH gradient interpolation?

Chrome and Edge 111+, Safari 16.2+ and Firefox 127+. Older browsers ignore the declaration, so the generated CSS includes an sRGB fallback line first.

What is the difference between OKLab and OKLCH?

They are the same perceptual space. OKLab blends in straight lines (even, slightly muted midpoints); OKLCH blends around the hue circle (vivid midpoints, and a choice of shorter or longer hue).

How do I make a hard colour stop?

Give two stops the same position, for example red 50% and blue 50%. The colour switches instantly instead of blending.

Can I use the result in Tailwind?

Yes. Copy the Tailwind class, an arbitrary value such as bg-[linear-gradient(...)] with underscores for spaces. Tailwind v4 also has bg-linear-*, bg-radial and bg-conic utilities with /oklch modifiers.

Why stack several box shadows?

One shadow looks flat. A tight dark layer plus a wide soft layer mimics how light behaves and reads as natural depth.

What does negative spread do?

It shrinks the shadow before blurring, so a large blur stays under the element instead of spilling out on every side.

Do gradients affect page speed?

Barely. They are drawn by the browser with no download, so they are lighter than background images. Animating large gradients is what costs performance.

Why does the colour picker not have transparency?

The browser's native colour input is opaque. For transparent stops, edit the copied CSS and use a colour with alpha, such as rgb(31 94 255 / 0) or transparent.

More free tools.

All tools

Need tooling like this inside your product?

We build internal tools, developer platforms and APIs. Tell us what your team keeps doing by hand.