conic-gradient()

Term side of the Card.
Topic: Background
Unit title: conic-gradient()
Categories: Function
Explanation side of the Card

Explanation: The function that creates a gradient that radiates from the center of a circle, resembling a pie chart. It allows creating complex, circular color transitions that can be used for backgrounds, charts or decorative elements.

Browser compatibility:
  • The chrome browser supports this feature starting from version 69.
  • The edge browser supports this feature starting from version 79.
  • The firefox browser supports this feature starting from version 83.
  • The safari browser supports this feature starting from version 12.1.
Availability: 

Example

Wrongcss
.pie {
  border-radius: 50%;
  background: conic-gradient(tomato, gold, teal);
}
Rightcss
.pie {
  aspect-ratio: 1;
  border-radius: 50%;
  background: conic-gradient(
    tomato 0 40%, gold 40% 75%, teal 75% 100%
  );
}

Hard stops at shared positions turn a smooth color sweep into clear pie slices.

Common mistakes

  • Slices blend into each other because the stops are not doubled at the same angle.
  • The chart starts from the wrong side; the gradient begins at the top unless from is set.

Key points

  • Pie slices use hard stops, where each color starts at the previous color's end.
  • A round pie sets border-radius: 50% and equal width and height, or aspect-ratio: 1.
  • Charts drawn with gradients have a text or ARIA alternative, since the gradient carries no data for screen readers.

Interview questions

Where does a conic gradient start?

At the top, going clockwise. Use from <angle> to rotate the start, for example from 90deg.

conic-gradient vs radial-gradient?

A conic gradient changes color around a center point. A radial gradient changes color outward from the center.

Analytics cookiesWe'd like to use analytics cookies to see which pages are useful. They're set only if you accept. Privacy Policy