A well-crafted gradient design creates a sense of depth and movement that a flat color simply cannot achieve. In recent years color transitions have made a comeback in interfaces, logos and backgrounds; used well they look modern and balanced, used poorly they look cheap and distracting. In this guide I walk through the types of transitions, the logic behind color selection, and CSS examples that actually work in the real world.
What a gradient is and why it works
A gradient is a smooth transition between two or more colors. Our eyes are far more accustomed to the light transitions found in nature than to hard edges; a sunset, a reflection on a metal surface or the edge of a shadow are all transitions. Using a gradient in design taps into that natural feeling, adding volume and warmth to surfaces. A flat color feels static, while a subtle transition makes a surface feel as though it is "catching the light."
Transitions serve three core purposes:
- Depth: they give buttons, cards and panels a gentle sense of volume.
- Direction: they guide the eye toward a specific point, such as a call-to-action button.
- Brand identity: a transition between two signature colors creates a memorable, recognizable signature.
Types of transitions and when to use them
CSS offers three main gradient types, each suited to a particular use case.
- Linear: colors flow along an axis. The most common choice for backgrounds, header areas and buttons.
- Radial: color spreads outward from a center. Ideal for spotlight effects, glows and focal points.
- Conic: colors rotate around a center. Useful for progress rings, pie charts and decorative patterns.
.hero {
/* linear: 135 degrees, top to bottom */
background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
}
.glow {
/* radial: soft light from a center */
background: radial-gradient(circle at 30% 20%, #f0abfc, transparent 60%);
}
Color selection: the secret to a balanced transition
Most failed gradients come down to the wrong color choice. The safest method is to pick colors that sit close together on the color wheel (analogous), such as blue-to-purple or orange-to-pink. Because the path between these tones is short, no muddy gray appears in the middle.
If you connect opposite (complementary) colors directly, a dirty gray often shows up in the middle of the transition. If you want to combine blue and orange, adding an intermediate color (such as purple or a soft gray) that smooths the path will rescue the result. A few practical principles:
- Stick to two or three colors; more than that makes control difficult.
- Don't open the lightness gap between colors too wide, or the transition turns into a harsh band.
- Build the transition thinking in HSL: shifting the hue while keeping saturation steady gives cleaner results.
Text legibility and accessibility
When you place text over a gradient background, the contrast ratio may be sufficient at one end of the text and insufficient at the other. WCAG recommends at least 4.5:1 contrast for normal text. Check the lightest and darkest points of the transition separately, and make sure the text remains readable at both.
A practical solution is to place a semi-transparent darkening layer behind the text:
.card {
background:
linear-gradient(rgba(0,0,0,0.45), rgba(0,0,0,0.45)),
linear-gradient(135deg, #0ea5e9, #6366f1);
color: #fff;
}
The top layer here darkens the entire surface evenly, so the text stays readable at every point of the transition. Alternatively, you can place the text in a narrow block with a solid color behind it.
Preventing the banding effect
In wide, smooth transitions, especially in dark tones, visible stripes can appear. This is called "banding" and stems from the limits of 8-bit color depth. A few solutions:
- Add a very subtle noise texture to the transition; it draws the eye away from the stripes.
- Use three or four stops instead of two to soften the transition curve.
- Where possible, avoid extremely low-contrast transitions across large areas.
In modern browsers, using the oklch() color space produces perceptually smoother transitions and reduces muddy intermediate tones:
.smooth {
background: linear-gradient(in oklch, #ec4899, #3b82f6);
}
Animated and dynamic transitions
An animated gradient can bring a page to life, but it must be used in moderation. By animating the background position you create a gentle flow:
.flowing {
background: linear-gradient(120deg, #6366f1, #ec4899, #f59e0b);
background-size: 200% 200%;
animation: shift 8s ease infinite;
}
@keyframes shift {
0% { background-position: 0% 50%; }
50% { background-position: 100% 50%; }
100% { background-position: 0% 50%; }
}
For users who are uncomfortable with motion, don't forget to disable the animation with a prefers-reduced-motion query. Accessibility comes before visual impact.
Frequently Asked Questions
Are gradients still modern?
Yes. The exaggerated, glossy transitions of the early 2010s are dated, but soft, low-contrast transitions with two or three colors are very common in today's interfaces. What matters is the dose and the color harmony.
Which browsers support conic gradients?
conic-gradient() is supported in all current desktop and mobile browsers. Unless you are targeting very old versions, you don't need extra measures; even so, it's a good habit to leave a solid-color fallback rather than relying on the gradient alone for a critical visual.
Should I use a gradient in my logo?
You can, but make sure the logo also works in single-color (black and white) and small-size versions. A logo that depends on a gradient may lose its identity on a fax, a stamp or a single-color print.
Looking for a balanced, modern visual language for your brand? Get in touch with me to build a color palette, a transition system and an actionable design guide.