CSS: Conic Gradient
What is conic-gradient
conic-gradient() creates gradients that rotate colors around a central point, forming effects like pie chart.
Basic Example
background-image: conic-gradient(red, white);
div.basic4824 { width: 200px; height: 200px; border-radius: 50%; background-image: conic-gradient(red, white); }
Example. Multiple colors
background-image: conic-gradient(red, white, green, yellow, blue);
Example. Custom start angle
background-image: conic-gradient(from 90deg, red, white);
Example. Custom center position
background-image: conic-gradient(from 90deg at 30% 40%, red, white);
Example. color stops
background-image: conic-gradient(red 50%, green 60%, yellow 70%);
Example. Create sharp edges
when 2 neighbor color stops are the same, there is a sharp edge.
background-image: conic-gradient(red 50%, yellow 50%, green);
Example. No sharp change
to avoid sharp color change at the start and end angle, specify the same color for the starting color and ending color.
background-image: conic-gradient(red, yellow, green, red);
Example. rainbow
background-image: conic-gradient(red, orange, yellow, green, blue, indigo, violet, red);
Example. HSL color
background-image: conic-gradient(in hsl shorter hue, red, white);
background-image: conic-gradient(in hsl longer hue, red, white);
Repeating Conic Gradient
Color wheel spinner animation
Basic Syntax
background-image: conic-gradient(?from-angle ?at-position, color-stop-list);
Sets the starting angle (default is 0deg).
- ?from-angle
-
Optional. Syntax is
from angleangle is any Angle Unit. e.g.
30deg,0.3turn - ?at-position
-
Optional. Syntax is
at positionexample
at center(default)at 50% 60%at topat left
- color-stop-list
-
List of colors, optionally with angular positions (e.g.
red 90deg).If you omit angles, colors spread evenly around the circle (360° / number of colors).
browser support
supported by all major browsers since 2021.