Developer Tools

CSS Gradients: Linear, Radial and Conic Explained Simply

Linear, radial and conic gradients demystified — direction angles, color stops, hard stops and repaint costs, with real CSS patterns you can copy today.

4 min read·Updated 2026-04-17

A CSS gradient is not an image — it is a function the browser paints. linear-gradient(), radial-gradient() and conic-gradient() generate smooth transitions between two or more colors entirely in CSS, with zero files and zero network requests. Understanding the gradient line and the color stops is everything: every fancy pattern in this guide is just those two ideas combined. This guide decodes all three gradient types and shows you when each one wins.

Linear gradients: the workhorse

linear-gradient() paints a smooth transition along an imaginary line. The first argument sets the direction; everything after that is a list of color stops:

background: linear-gradient(to right, #ff7e5f, #feb47b);
background: linear-gradient(45deg, #6366f1, #a855f7);
background: linear-gradient(to top right, #f59e0b, #ef4444);

Keywords (to bottom, to right, to top left) cover the basics, and angles from 0deg to 360deg give precise control. Angles are measured clockwise from the top of the element: 0deg points up, 90deg points right, 180deg points down.

Radial gradients: glow from a center

radial-gradient() begins at a center point and fades outward in circles or ellipses. You set the shape, the size and the center position, then list stops:

background: radial-gradient(circle at center, #6366f1, #1e1b4b);
background: radial-gradient(ellipse at top, #fde68a, transparent 70%);
background: radial-gradient(circle at 20% 30%, #22c55e, #14532d);

The transparent stops beat opacity for vignettes because transparency interpolates through the RGB channels instead of compositing a colored box that is then faded — subtle but visible on busy backgrounds.

Conic gradients: the sweep

conic-gradient() sweeps color around a point like the sweep of a radar, making it the gradient of pie charts, color wheels and clock faces:

background: conic-gradient(from 0deg, #fbbf24, #ef4444, #3b82f6, #fbbf24);
background: conic-gradient(from 180deg at 50% 50%, #a855f7, #ec4899);

Each segment of equal width becomes a slice of a chart, and adding a mask or border-radius makes it look like a proper pie chart with no SVG at all.

The three gradients, compared

GradientPaints alongShapeBest for
linear-gradient()A straight line in a directionBand, angledButtons, headers, depth and shine
radial-gradient()Rings from a center pointCircle or ellipseGlows, vignettes, spotlight effects
conic-gradient()An arc around a centerWedge slicesPie charts, color wheels, spinners

How the gradient line really works

For a linear gradient, draw a line through the element's center rotated to your chosen angle. The paint projects every color stop onto that line, so at 45deg the gradient line is longer than the element itself and the transition uses more room. This is why gradients at angles look compressed near the corners — the gradient line scales to cover the box diagonal, not the straight distance between your stops.

Color stops and hard stops

A stop is a color plus an optional position. Without positions, stops are evenly spaced; with positions, you control the pacing. Three rules cover almost every gradient you will write:

  • Evenly spaced by default — two stops land at 0% and 100%, three stop at 0%, 50% and 100%.
  • Positions override pacing — red 0%, orange 50%, yellow 100% lifts the whole transition onto the line you choose.
  • Equal positions create hard edges — two stops at the same point switch colors instantly, which is the trick behind striped rows and progress bars.

Hard stops are written by giving two stops the same position: linear-gradient(90deg, #e5e7eb 0 50%, #ffffff 50% 100%) splits the element cleanly in half. For repeating patterns, the repeating forms cycle the stop list, and their performance is identical to one-shot gradients for the same painted area:

background: repeating-linear-gradient(45deg, #e5e7eb 0 12px, #ffffff 12px 24px);

Removing banding from smooth transitions

Long, high-contrast gradients can show visible banding where steps align. Fix it by inserting extra mid stops: instead of two colors, pass three or four interpolated ones, or add a subtle mid-stop such as linear-gradient(90deg, #1d4ed8, #3b82f6 35%, #60a5fa 70%, #93c5fd). Delivering more stops spreads the interpolation so the eye cannot find a seam. Then convert your chosen hues to consistent values with the Color Converter so every stop belongs to the same family of tones.

Build gradients visually

The Gradient Generator gives you live previews for all three types — pick the direction, shape and stops, tweak until it feels right, then copy the one-line CSS. Layer depth underneath with the Box Shadow Generator, and keep every hue coordinated by converting between hex, rgb and hsl with the Color Converter.

Frequently asked questions

Do gradients hurt page performance? Only when overused. A gradient is painted once and cached with the element; the cost is in blur-heavy effects layered on top, which the compositor repaints when animated. For static UI, thousands of gradient backgrounds are fine.

Can a gradient be animated without repaints? Transitions on a plain background-image cannot interpolate. Animate gradients at 60 fps by registering the value as a CSS custom property with @property, then animating the property itself — browsers can interpolate registered numbers and color stops smoothly.

How do I make gradient text? Use background as a linear-gradient, then set background-clip: text and color: transparent. The gradient colors clip to the glyphs. Add a fallback color for browsers or for users who disable that rendering path.

Tools used in this guide

Related guides