# CSS Gradient Generator

> Build linear, radial, conic and repeating gradients, mix colours in OKLab or OKLCH so the middle stays bright, and copy CSS with an sRGB fallback or a Tailwind class.

- Page: https://codethatmoves.com/tools/motion/css-gradient-generator/
- Site: Code That Moves
- Category: Motion and CSS
- Free, runs in the browser, nothing is uploaded
- Last checked: 2026-11-03

## What it does

- Linear, radial (circle or ellipse) and conic gradients, plain or repeating
- Up to 12 colour stops: drag them on the bar or move them with the arrow keys, click the bar to add one, or type the position
- Per-stop opacity for fades to transparent, written as 8-digit hex
- Direction keywords (to right, to top left) as well as angles
- Colour interpolation in sRGB, linear sRGB, OKLab, OKLCH (short or long hue), CIE Lab and LCH, HSL or Display P3
- CSS with an sRGB fallback line for browsers without interpolation support
- Tailwind v4 utilities (bg-linear-*, bg-radial, bg-conic-* with from, via and to) or an arbitrary value class
- Gradient text CSS with background-clip: text
- Warns about a grey dip between far-apart hues and about repeating gradients that never repeat
- The whole gradient lives in the link, so you can share or bookmark it

## How to use it

1. Start from a preset or the default. Pick Linear, Radial or Conic and set the angle or the centre.
2. Edit the colour stops: pick a colour, type a hex value, set the opacity, and drag the handles on the bar. Click the bar to add a stop, or reverse them.
3. Choose how colours mix. OKLab or OKLCH keeps the middle of a gradient from going grey. Copy the CSS, the Tailwind class or the share link.

## What it checks and why

A CSS gradient is an image generated by the browser, so it costs no download and stays sharp at any size. linear-gradient runs along a line at an angle, radial-gradient spreads from a centre point as a circle or ellipse, and conic-gradient turns around a centre like a colour wheel. The repeating- forms tile the stops, which makes stripes and rings.

Gradients mix colours in sRGB by default, and sRGB is not perceptually even. Blue to yellow in sRGB passes through a dull grey, because the channels cancel each other halfway. CSS Images 4 and CSS Color 4 add a colour interpolation method: linear-gradient(in oklab, …) mixes in a space built to match how people see lightness, so the midpoint stays clean. in oklch also keeps the chroma and travels around the hue wheel; longer hue takes the long way round and gives a rainbow from two stops.

A browser that does not understand the in <colorspace> syntax drops the whole declaration. The tool therefore writes an sRGB line first and the interpolated line second. Browsers that understand the second one use it, the rest keep the first.

I use OKLCH for the colours on this site, and the OKLCH converter turns any hex or rgb value into oklch() if you want to write the stops by hand.

## Specs and sources

- [CSS Images Module Level 4: gradients](https://www.w3.org/TR/css-images-4/#gradients)
- [CSS Color Module Level 4: color interpolation](https://www.w3.org/TR/css-color-4/#interpolation)
- [MDN: <gradient>](https://developer.mozilla.org/en-US/docs/Web/CSS/gradient)
- [MDN: <color-interpolation-method>](https://developer.mozilla.org/en-US/docs/Web/CSS/color-interpolation-method)
- [Tailwind CSS: background-image (gradients)](https://tailwindcss.com/docs/background-image)

## Limits

- Stops are hex colours (with an optional alpha). To use oklch() or named colours, copy the CSS and replace the values; the gradient syntax stays the same.
- Tailwind v4 utilities are offered for up to three stops in sRGB, OKLab, OKLCH or HSL, because from, via and to cover three stops; other gradients get the arbitrary class.
- One gradient per output. Layered backgrounds with several gradients are not built here, though you can stack the copied values with commas.
- Stops use percentages. Lengths such as 20px and double-position stops are valid CSS but not offered in the editor.
- The grey-middle warning is a rough hue check on the hex values, not a full colour-science test.

## Questions

### How do I make a gradient without the grey middle?

Mix in a perceptual space: linear-gradient(in oklab, blue, yellow) or in oklch. Pick OKLab or OKLCH under Colour mixing and the tool writes it with an sRGB fallback.

### What is the difference between OKLab and OKLCH gradients?

OKLab mixes in a straight line, so opposite colours meet at a soft neutral. OKLCH moves around the hue wheel and keeps saturation, so blue to yellow passes through green or pink and stays vivid.

### Do browsers support in oklch in gradients?

Current Chrome, Edge, Firefox and Safari do. Older browsers ignore the whole value, which is why the copied CSS has an sRGB line first.

### How do I make stripes with CSS?

Use repeating-linear-gradient with hard stops: two stops of one colour and two of another at the same positions, for example 0% 5% and 5% 10%. Try the Stripes preset.

### How do I use a custom gradient in Tailwind?

In Tailwind v4, copy the utilities: bg-linear-135/oklch from-[#7cc4ff] via-[#c4a1ff] to-[#ff9fc4]. Tailwind v4 mixes in OKLab by default, and a modifier such as /oklch or /srgb changes it. For more than three stops, or in Tailwind 3, copy the arbitrary class bg-[linear-gradient(...)], with spaces written as underscores.

### How do I fade a gradient to transparent?

Give the last stop the same colour with zero opacity, for example #7cc4ff to #7cc4ff00, instead of the keyword transparent. Fading to transparent black can leave a grey band in sRGB; the same colour at zero opacity does not. Use the opacity slider on the stop.

### How do I make gradient text in CSS?

Set the gradient as the background, then background-clip: text (with the -webkit- prefix too) and color: transparent. Copy as gradient text writes all four lines.

### Can I animate a CSS gradient?

Not directly between two gradients in most browsers. Animate background-position on a larger gradient, or register custom properties with @property and animate those.
