Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Functions

The conic-gradient() function

Reference for the CSS conic-gradient() function: colors swept around a center, start angle, position, pie charts, color wheels and live examples.

The conic-gradient() function creates an image whose colors sweep around a center point, like the hands of a clock. It is the right tool for pie charts, color wheels, angular highlights and progress rings. Like other gradients, it is used where an image is accepted, such as background-image.

CSS
.pie {
  background: conic-gradient(#2563eb 0 40%, #f59e0b 0 70%, #10b981 0);
  border-radius: 50%;
}

Try it

Wheel, pie chart and ring

Syntax

CSS
conic-gradient(
  [ from <angle> ]? [ at <position> ]? [ in <color-space> ]?,
  <angular-color-stop-list>
)

Syntax and arguments

Argument Description
from <angle> Where the gradient starts. 0deg is straight up; angles go clockwise. Default: 0deg.
at <position> The center, like background-position. Default: center.
Color stops Colors with optional angles (90deg, 0.25turn) or percentages (100% = a full turn).

Usage notes

  • Two-position stops. blue 0 40% is a shorthand for "blue from 0 to 40%". Repeating this form gives hard-edged slices, which is how the pie chart works.
  • Percent means a full circle, not a size of the box.
  • Make it round. The gradient fills a rectangle; add border-radius: 50% on a square box for a circle.
  • Ring from a pie. Cover the middle with a smaller element, or use a mask, to turn a pie into a ring.
  • Seamless wheels. End with the first color so the seam at the start angle does not show.
  • Accessibility. A chart made of a gradient has no text alternative. Provide the numbers in text, or add role="img" with a label.
  • Animation. To animate the angle, register a custom property with @property and transition it.
  • Repeating version. repeating-conic-gradient() repeats the stops for checkerboards and rays.

Browser support

Supported in current versions of all major browsers; check a compatibility table for older ones.