Gradients that don’t band
By Theo Lane (pen name; AI-assisted, hand-checked) ·
Gradients are back in interface design, and with them two old problems: muddy midpoints and visible stripes called banding. Both have well-understood causes and simple fixes.
Problem one: the muddy middle
By default, CSS and most design tools interpolate gradients in sRGB: they average the red, green and blue values. When two endpoint colors are far apart in hue — blue and yellow, say — the average of their channels is a desaturated gray-ish color. The result is a dull band in the middle of what should be a vivid transition.
Interpolating in a perceptual space fixes this. In OKLab, a straight line between two colors keeps perceived lightness changing steadily and avoids the dip in chroma. In OKLCH, interpolation walks around the hue wheel, keeping chroma high all the way — great for rainbow-like transitions, though it can introduce hues you did not expect if the endpoints are far apart. CSS Color 4 lets you choose:
background: linear-gradient(in oklab, #1d4ed8, #facc15);
background: linear-gradient(90deg in oklch, #1d4ed8, #facc15);
background: linear-gradient(in oklch longer hue, red, red);
All current major browsers support this syntax. For older ones, Palg’s gradient maker writes a fallback line with extra precomputed stops so the transition still looks perceptual.
Problem two: banding
Banding happens when a gradient spans a large area but there are only a few distinct color values available along it. An 8-bit-per-channel display has 256 levels per channel; a gradient from #1a1a2e to #16213e across a 1600-pixel hero has only a handful of distinct values per channel, so each value is drawn as a stripe many pixels wide. Our eyes are especially good at spotting edges in dark, low-contrast regions, which is why dark gradients band most visibly.
Fixes, roughly in order of effort:
- Increase the range. A gradient that moves further in lightness or chroma has more distinct values to spread over the same area.
- Shorten the distance. Use the gradient over a smaller area, or add a mid stop that redistributes change.
- Avoid near-black endpoints for large, subtle gradients. Shift the dark end up slightly.
- Add noise. A subtle noise texture (1–3% opacity) dithers the steps so the eye cannot find edges. In images, add noise before compressing.
- Export carefully. JPEG and low-quality WebP compression make banding worse by quantizing smooth regions. Use PNG, high-quality WebP or AVIF for gradient-heavy images, and prefer CSS gradients over bitmaps when you can, since browsers may render them with dithering.
Choosing gradient colors
- Analogous endpoints (hues within about 60°) produce smooth, natural transitions in any space.
- Complementary endpoints pass through gray in sRGB and through a range of hues in OKLCH. If neither looks right, add a deliberate mid stop.
- Keep lightness monotonic unless you want a glow effect. A gradient that gets lighter then darker reads as a highlight or a shape.
- Check text contrast across the whole gradient. Text over a gradient must pass against the lightest and the darkest point behind it.
Linear, radial, conic
Linear gradients suit backgrounds and buttons. Radial gradients suggest light sources and depth; keep them subtle in UI. Conic gradients sweep around a point and are useful for pie charts, color wheels and decorative rings. SVG supports linear and radial gradients natively but not conic, so export conic designs as CSS or PNG.
Accessibility and motion
Animated gradients can be distracting or trigger discomfort for people with vestibular disorders. Respect prefers-reduced-motion and keep animations slow and optional.
Gradients in design systems
If gradients are part of your brand, treat them like any other token. Name them by purpose (hero background, promotional banner, chart highlight) rather than by color, store the stops and interpolation space in code, and document where each may appear. A gradient defined once as a CSS custom property — for example --gradient-hero — is easy to update everywhere when the palette changes, and it keeps teams from improvising slightly different blends that drift apart over time. Pair each gradient with the text color that is approved on top of it and the contrast ratio measured at its weakest point, so that nobody has to guess whether a headline will be readable.
Workflow in Palg
- Open the gradient maker and set two stops.
- Toggle between sRGB and OKLCH and compare the strips beneath the preview.
- Add a mid stop if the transition still looks off.
- Copy the CSS (with fallback), or export SVG or PNG.
- Save it to your library next to the palette it belongs to.