Skip to content
ColorArchive
Visual Design
Search intent: gradient design UI CSS gradient background gradient palette

Gradients in UI Design: Functional vs Decorative and How to Use Both

A framework for using gradients well — understanding what gradients communicate, avoiding common failures like the muddy middle, and building gradients that survive palette changes.

UI DesignCSSColor TheoryVisual Design
Key points
Gradients transitioning between hues via HSL interpolation often produce a desaturated 'muddy middle' — OKLCH interpolation solves this with perceptually uniform transitions.
A gradient communicates movement, depth, and energy simultaneously; when those signals conflict with the design's intent, the gradient adds noise rather than meaning.
Define gradients as named tokens in design systems (--gradient-hero-background) rather than ad-hoc in components — rebrand updates propagate automatically.

What gradients communicate

Before deciding whether to use a gradient, understand what it will communicate. Gradients communicate three things simultaneously: movement (the eye follows the gradient's direction of transition), depth (a gradient from lighter at the top to darker at the bottom reads as a surface curving away from the viewer), and energy (high-saturation gradients read as dynamic and playful; muted gradients read as calm and sophisticated). When these effects align with design intent, a gradient adds meaning. When they conflict — a 'trustworthy, stable, financial' brand using a vivid, high-energy gradient — the gradient creates visual noise by implying qualities the brand does not intend. The design question before adding a gradient is always: what does this specific gradient communicate, and does that match what this surface needs to say?

The muddy middle problem and perceptual gradients

The most common gradient failure is the muddy middle: a gradient between two pure hues that passes through an unpleasant, desaturated zone at the midpoint. A gradient from red to blue interpolated through HSL crosses the hue wheel through purple-to-near-gray in a way that looks muddy and unintended. The problem is that HSL is not a perceptually uniform color space — equal steps in HSL produce unequal perceptual steps, and hue transitions between some color pairs cross through near-gray zones. The solution is perceptual color space interpolation. CSS now supports OKLCH gradients: background: linear-gradient(in oklch, red, blue) produces a vivid, perceptually uniform transition through violet rather than the muddy HSL path. For any hue-to-hue gradient, OKLCH is the correct interpolation space.

Functional gradient applications

Several functional gradient patterns are reliable across interface types. Surface depth on cards: a very subtle top-to-bottom lightness gradient (2-3% lightness difference) on a large card surface reads as physical depth without drawing attention to itself. Text legibility overlay: a gradient from transparent to 60-70% black at the bottom of a photographic area ensures text contrast without a hard edge line — ubiquitous in media, content, and hero sections. Focus and attention gradient: a radial gradient glow behind a featured element or active state uses the eye-following property of gradients to draw attention to the active component. Status gradients: subtle background gradients in success/warning/error banners add visual distinctiveness to feedback without relying solely on color hue, which is important for color-blind accessibility.

Gradients in design systems

Gradients are harder to maintain in design systems than flat colors because they are defined by multiple color stops, not a single value. When brand colors change, gradient definitions must be manually updated. The solution is gradient tokens: define named gradient presets with semantic references — --gradient-hero-background: linear-gradient(in oklch, var(--brand-primary-light), var(--brand-primary-dark)). Component gradients reference the gradient token rather than raw values. When the brand palette changes, updating the primitive tokens automatically updates every gradient token, which automatically updates every component using it. Ad-hoc gradients defined with raw hex values in component files are a maintenance debt. Audit for them regularly and migrate to token references.

Practical next step

Move from the guide into a concrete palette lane

Guides explain the use case. Collections prove the taste. Packs handle the export and implementation layer.

Related guides