What it does
The generator writes a CSS background declaration for the three gradient functions in CSS Images: linear-gradient(), radial-gradient() and conic-gradient(), plus their repeating- versions. Colors are written as lowercase HEX, or 8-digit HEX when a stop is transparent. The preview, the settings and the shareable link are all handled in your browser.
| Type | Colors change along | Example output |
|---|---|---|
| Linear | A straight line at an angle | linear-gradient(90deg, …) |
| Radial | Outward from a center point | radial-gradient(circle at center, …) |
| Conic | Around a center point, like a clock hand | conic-gradient(from 0deg at center, …) |
How the angle and stops work
In linear-gradient(), 0deg points up and angles turn clockwise, so 90deg runs left to right and 180deg (the default) runs top to bottom. The keyword directions such as to top right aim at the box's corner, so their real angle depends on the box's shape; the quick buttons here write fixed angles instead. For a conic gradient, the from angle rotates where the first color starts, again with 0deg at the top.
Each stop's percentage is a point along the gradient line (or around the circle for conic). Two stops at the same position make a hard edge, which is how the stripes preset works. In a repeating gradient, the stops from first to last form one tile that repeats, so stops ending at 10% repeat ten times along the gradient line.
Interpolation color spaces
CSS Images Level 4 lets a gradient say which color space to blend in, such as linear-gradient(90deg in oklch, …). When the stops are HEX, rgb(), hsl() or named colors and no space is written, browsers blend in sRGB, as they always have. Blending in sRGB can turn the middle of a gradient gray or muddy; Oklab keeps lightness more even; OKLCH also keeps chroma, so the middle stays vivid, and it can take the shorter or longer way around the hue wheel.
Support for the in <color space> syntax arrived in Chrome and Edge 111, Safari 16.2 and Firefox 127, according to MDN's compatibility data. Older browsers treat the whole declaration as invalid and skip it, so when you choose a space the tool writes a plain line first. That line is the fallback; browsers that understand the second line use it instead.
Worked example
Stops #4F46E5 at 0% and rgb(245, 158, 11) at 100%, angle 135, color space in oklch, produce:
background: linear-gradient(135deg, #4f46e5 0%, #f59e0b 100%); background: linear-gradient(135deg in oklch, #4f46e5 0%, #f59e0b 100%);
and the Tailwind class bg-[linear-gradient(135deg_in_oklch,#4f46e5_0%,#f59e0b_100%)]. The color halfway along differs by space. In sRGB it is #a27278, a dusty pink. In Oklab it is #9b82a2, a grayish mauve. In OKLCH the hue takes the shorter path from 276.97° to 70.08° through 353.52°, giving a vivid #e04b95. These midpoints are computed by this tool's own conversion code; browsers may round slightly differently.
Tailwind CSS classes
With a gradient value, Tailwind's bg-[…] arbitrary value sets background-image. (Tailwind v4's own bg-linear-* utilities blend in Oklab by default; the class here copies your CSS exactly instead.) Spaces are not allowed inside a class name, so each space becomes an underscore, which Tailwind turns back into a space at build time. The class has no fallback line, so if you use a color space and need older browsers, use the CSS instead. Tailwind CSS v4 also has its own bg-linear-*, bg-radial and bg-conic utilities with from-, via- and to- colors.
Common mistakes
- Using
background-color. A gradient is an image, so it goes inbackgroundorbackground-image. - Expecting
0degto run left to right. In CSS, 0deg points up; left to right is 90deg. - Stops out of order. A stop placed before an earlier one is moved up to the earlier position, which creates an unexpected hard edge.
- Text over a gradient. Check the text's contrast against both the lightest and darkest parts it covers.
Tailwind CSS is made by Tailwind Labs. Dev Kit Bag is not affiliated with or endorsed by Tailwind Labs.