conic-gradient()
Creates a colour transition around a point, like a clock hand. It draws pie charts, colour wheels, and rotating borders.
Example
#.chart {
width: 120px;
aspect-ratio: 1;
border-radius: 50%;
background: conic-gradient(
#7c3aed 0 40%,
#0ea5e9 0 75%,
#10b981 0
);
}<div style="display: flex; flex-wrap: wrap; align-items: center; gap: 20px;">
<div class="chart" role="img" aria-label="HTML 40%, CSS 35%, JavaScript 25%"></div>
<ul style="display: grid; gap: 6px; margin: 0; padding: 0; list-style: none;">
<li><span style="color: #7c3aed;">■</span> HTML: 40%</li>
<li><span style="color: #0ea5e9;">■</span> CSS: 35%</li>
<li><span style="color: #10b981;">■</span> JavaScript: 25%</li>
</ul>
</div>Each colour starts at 0, that is, where the previous one ended. You only need to say where it should reach.
Definition and usage
#The conic-gradient() function spreads colours around a circle about its centre, clockwise, starting from the top. The colour changes with the angle, not with the distance from the centre as in radial-gradient(). The result is an image, so you put it in background or background-image.
You give colour positions in degrees or as percentages of a full turn: #7c3aed 0deg 120deg fills one third of the circle. Two colours at the same position give a hard edge, so from several ranges you can build a pie chart without any graphics. With border-radius: 50% the element becomes round.
The word from rotates the starting point (from 90deg starts on the right), and at moves the centre (at 30% 40%). For a smooth colour wheel the last colour should be the same as the first, otherwise a sharp edge appears at the top.
The repeating-conic-gradient() version repeats the pattern, which lets you draw a checkerboard in one declaration, for example repeating-conic-gradient(#27272a 0 25%, #3f3f46 0 50%) with background-size. By animating the from angle through a variable registered with @property, you can make a rotating border or a loading indicator.
Syntax
#conic-gradient([from <angle>]? [at <position>]?, <color> <angle>?, <color> <angle>?, …)Syntax variants
#smooth rotation of colours
Rainbow colours spread around. The last is the same as the first, so there is no sharp edge at the top.start on the right
The wordfromrotates the starting point. The amber quarter starts at three o’clock instead of twelve.shifted centre
Afteratyou give the position of the centre. The colours converge in the upper left part of the circle.40%, 35% and 25%
Hard ranges instead of transitions. Each colour starts at0, that is, where the previous one ended.65%
A 65% slice on a grey background, and a mask with a radial gradient cuts out the centre, so a ring is left of the circle.checkerboard
A repeated pattern of two quarters in a 22 × 22 px tile. This is how you draw a checkerboard, for example under transparent images.
Syntax variants in practice
#colour wheel
.demo {
background: conic-gradient(red, yellow, lime,
aqua, blue, magenta, red);
}from 90deg
from rotates the starting point. The amber quarter starts at three o’clock instead of twelve..demo {
background: conic-gradient(from 90deg,
#f59e0b 0 25%, #27272a 0);
}at 30% 30%
at you give the position of the centre. The colours converge in the upper left part of the circle..demo {
background: conic-gradient(at 30% 30%,
#7c3aed, #0ea5e9, #10b981, #7c3aed);
}pie chart
0, that is, where the previous one ended..demo {
background: conic-gradient(#7c3aed 0 40%,
#0ea5e9 0 75%, #10b981 0);
}progress ring
.demo {
background:
conic-gradient(#10b981 65%, #27272a 0);
mask: radial-gradient(closest-side,
transparent 68%, #000 69%);
}repeating-conic-gradient()
.demo {
border-radius: 12px;
background: repeating-conic-gradient(
#27272a 0 25%, #a1a1aa 0 50%) 0 0 / 22px 22px;
}Browser support
#Widely available · since 2020
Works in all modern browsers, phones included. You can use it without worry.
- Chrome
- Edge
- Firefox
- Safari
Good practices
#- In pie charts give the start position as
0: the browser starts the colour where the previous one ended, and you don’t have to repeat numbers. - A chart made in CSS isn’t readable to screen readers. Add a legend with the values next to it or a description in
aria-label. - You can make a rotating gradient by animating
from var(--angle)with a variable registered through@propertyas<angle>.
Related entries
#- linear-gradient()Creates a smooth colour transition along a straight line. It is used as an image, most often in background or background-image.
- radial-gradient()Creates a colour transition radiating outwards from a point, along a circle or an ellipse. Good for glows, vignettes, and soft lights.
- @propertyRegisters a CSS variable with a type, an initial value, and an inheritance rule. Such a variable can be animated smoothly, e.g. a gradient angle.
- background-imageSets an image or gradient as an element’s background.
- border-radiusRounds the corners of an element.
Spotted a mistake or missing an example? Write to us.