Quick answer
A CSS gradient is an image the browser draws from color stops: linear-gradient() blends along a straight line, radial-gradient() spreads out from a point, and conic-gradient() sweeps around one. In Playxoft's free CSS Gradient Generator, pick a type, click the color bar to add stops, drag them into place and choose an interpolation color space such as OKLab, then copy the CSS, Tailwind class or Sass variables.
- Linear, radial and conic
- Draggable color stops
- OKLab and OKLCH blending
- Layered gradients
- Fallbacks for older browsers
- Paste existing CSS to edit
- CSS, Tailwind and Sass
- Undo, redo and share links
How to use the CSS Gradient Generator
- 1Choose Linear, Radial or Conic in the toolbar, or start from one of the Presets below the editor.
- 2Click the color bar to add a stop, drag stops to move them, and drag a stop off the bar (or press Delete) to remove it.
- 3Set the selected stop's Stop color, Opacity and Position. Two stops at the same position make a hard edge.
- 4Pick an Interpolation color space: OKLab for smooth, even blends or OKLCH for vivid sweeps around the hue wheel.
- 5Already have a gradient? Open Paste existing CSS in the controls and import it to keep editing every layer.
- 6Stack extra Layers for mesh-style backgrounds, then copy the CSS, Tailwind or SCSS tab, or press Share to copy a link to the design.
Linear vs radial vs conic gradients: which should I use?
All three are CSS <image> values, so they go anywhere an image does: background-image, border-image, mask-image and list-style-image. They differ in the path the colors travel along.
| Function | Colors travel | Typical uses | Key syntax |
|---|---|---|---|
linear-gradient() | Along a straight line at an angle | Buttons, hero sections, overlays that darken an image for text | linear-gradient(135deg, …) |
radial-gradient() | Outward from a center, as a circle or ellipse | Glows, spotlights, vignettes, soft "blob" shapes | radial-gradient(circle at 30% 20%, …) |
conic-gradient() | Around a center, like a clock hand | Pie charts, color wheels, loading rings, starbursts | conic-gradient(from 90deg at 50% 50%, …) |
Angles follow the CSS convention: 0deg points up and angles turn clockwise, so 90deg means "to right". Each function has a repeating- version that tiles the stop pattern, which is how stripes and rings are made without an image file.
How do CSS color stops work?
A color stop is a color plus an optional position along the gradient line. Stops without positions are spread evenly, and the first and last default to 0% and 100%. Between two stops the browser blends; before the first and after the last it holds the color flat.
/* Even spread */
background: linear-gradient(90deg, #3b82f6, #a855f7, #ec4899);
/* Hard edge: two stops share 50%, so there is no blend */
background: linear-gradient(90deg, #0ea5e9 50%, #f97316 50%);
/* Stripes with a repeating gradient */
background: repeating-linear-gradient(45deg, #facc15 0 10px, #18181b 10px 20px);Three details trip people up:
- Double positions like
#18181b 10px 20pxare shorthand for two stops of the same color, which is the cleanest way to write bands. - Transparent stops blend with premultiplied alpha in modern browsers, so fading
#ec4899totransparentno longer passes through gray. Using the same color at 0% opacity (#ec489900) is still the most predictable choice, and it is what this generator writes. - Color hints (a bare percentage between two stops, such as
red, 30%, blue) move the midpoint of a blend without adding a color.
What does in oklch do, and why do gradients look muddy or banded?
The interpolation color space decides how the browser mixes two stops. If every stop is a legacy color (hex, rgb(), hsl() or a name), the browser blends in sRGB; if any stop uses a modern syntax such as oklch() or lab(), the default becomes OKLab. sRGB mixes channel numbers rather than perceived color: blue to yellow passes through a dull gray in the middle (the "dead zone"), and red to green meets in a dark olive. CSS Color Module Level 4 lets you choose the space with an in clause.
| Clause | How it mixes | Use it for |
|---|---|---|
(none) / in srgb | Raw sRGB channel values | Matching older designs exactly |
in srgb-linear | Physical light, before gamma | Light-like blends with bright midpoints |
in oklab | Perceptually uniform lightness and color | The best general default: even and clean |
in oklch | Lightness, chroma and hue as a polar wheel | Vivid sweeps that keep their saturation |
in oklch longer hue | The long way round the hue wheel | Rainbows and color wheels from two stops |
Banding, the visible steps in a long and subtle gradient, is a different problem: an 8-bit display only has 256 levels per channel, so a dark navy fade across a wide hero runs out of in-between colors. Perceptual spaces spread those steps more evenly, adding a midpoint stop helps, and a faint noise texture layered on top hides what remains. Browsers that do not support the in clause drop the whole declaration, so turn on Fallbacks and the generator writes an sRGB version sampled from the same colors first.
How do I layer gradients for mesh-style backgrounds?
background-image accepts a comma-separated list, and the first image paints on top. Layering several soft radial-gradient() blobs that fade to transparent over a solid base gives the "mesh gradient" look with no image file at all. The rule that makes it work: every layer except the bottom one needs transparent regions, or it hides everything beneath it.
Use the Layers list to add, reorder, hide and duplicate layers, and drag each radial layer's center on the preview. The Aurora and Pastel mesh presets are good starting points.
Are CSS gradients good for performance?
Yes. A gradient is generated by the browser, so it costs no network request, stays sharp at any size and on any pixel density, and usually weighs a few dozen bytes of CSS instead of kilobytes of PNG. Painting even many layers is fast.
The cost appears when you animate them. Changing a gradient's colors or angle every frame repaints the whole element. Prefer animating transform or opacity on a pseudo-element that holds the gradient, or animate background-position on an oversized gradient. To animate an angle smoothly, register it as a typed custom property:
@property --angle {
syntax: "<angle>";
inherits: false;
initial-value: 0deg;
}
.spin {
background: conic-gradient(from var(--angle), #3b82f6, #ec4899, #3b82f6);
animation: spin 4s linear infinite;
}
@keyframes spin { to { --angle: 360deg; } }Wrap decorative motion in @media (prefers-reduced-motion: no-preference), and avoid background-attachment: fixed on large gradients, which scrolls poorly on many phones. To pair a gradient with a matching shadow or glass panel, see the box-shadow generator and the glassmorphism generator.
Frequently asked questions
Last updated by the Playxoft engineering team.