CSS and web

CSS conic gradient: wheels, pie charts and sheen

conic-gradient() sweeps colour around a point like the hand of a clock. That one idea draws colour wheels, pie charts, donut charts, metallic sheen and starbursts.

GradientlyVerified Gradiently account··4 min read
Cover: Found Dynamo · GR·787F·7V

The short version

  • A CSS conic gradient places colours around a centre point, sweeping clockwise from the top, instead of along a line or outwards in rings.
  • Colour stops in a conic gradient use angles or percentages of a full turn, so 25% and 90deg mean the same position.
  • Hard stops turn a conic gradient into slices, which is the quickest way to draw a pie chart in CSS.
  • The from keyword rotates where the sweep starts, and at moves the centre point.
  • repeating-conic-gradient() repeats its stops around the circle and, combined with background-size, draws checkerboards and starbursts.
On this page

A CSS conic gradient sweeps colour around a centre point, the way a clock hand sweeps around its face. Where a linear gradient changes along a line and a radial gradient changes outwards from the centre, conic-gradient() changes with the angle. It starts at the top, runs clockwise, and is used anywhere CSS takes an image. That makes it the natural tool for colour wheels, pie charts, loading rings and the angular highlights of brushed metal.

A simple colour wheelconic-gradient(#ef4444, #eab308, #22c55e, #06b6d4, #3b82f6, #a855f7, #ef4444)
Seven stops, spread evenly around a full turn. Repeating the first colour at the end closes the seam at the top.

If you are choosing between gradient types for a design rather than learning the syntax, types of gradients and the design guide to conic gradients are better starting points.

The conic-gradient() syntax

css
/*               start angle   centre        stops */
conic-gradient(from 90deg at 30% 50%, #0ea5e9, #6366f1, #0ea5e9)

/* stops as angles or as percentages of the turn */
conic-gradient(#f59e0b 0deg 90deg, #1e293b 90deg)
conic-gradient(#f59e0b 0% 25%, #1e293b 25%)
Everything before the first comma is optional. Both stop lists on the last two lines draw the same quarter slice.
PartExampleDefault
Start anglefrom 45degfrom 0deg, straight up
Centreat 30% 50%, at top leftat center
Interpolationin oklch, in hsl longer huesRGB for hex colours
Stop position90deg, 0.25turn, 25%spread evenly around the turn
The parts of conic-gradient(). Stop positions measure around the circle, not along a line.

Angles run clockwise from the top: 90deg is three o'clock, 180deg is six. The full definition is on MDN's conic-gradient() page. Browser support has been universal in current Chrome, Edge, Safari and Firefox for years, so no prefixes are needed.

Rotating and moving the sweep

from rotates the whole gradient, which is handy when the seam between the first and last colour would otherwise sit at the top. at moves the centre. Moving it to a corner turns the wheel into a fan of rays, and moving it off the box entirely gives a gentle angled wash that looks nothing like a wheel.

The same indigo, violet and pink family, rotated and moved. In the corner version, a quarter turn fills the box.

Pie charts and donut charts in CSS

Give every slice a start and an end, and let each start where the last one finished. Writing 0 as the second stop position is a shortcut: a position smaller than the previous one is clamped to it, so the new colour starts exactly where the last ended. Round the element with border-radius: 50%, and cut a hole with a radial mask to turn the pie into a donut.

css
.pie {
  width: 12rem;
  aspect-ratio: 1;
  border-radius: 50%;
  background: conic-gradient(
    #6366f1 0 40%,   /* 40% */
    #22d3ee 0 65%,   /* 25% */
    #f59e0b 0 85%,   /* 20% */
    #e2e8f0 0        /* the rest, 15% */
  );
}

.donut {
  /* same background as .pie, then a hole */
  mask: radial-gradient(farthest-side, transparent 58%, #000 59%);
}
A four-slice pie, and the one line that turns it into a donut. Use custom properties for the percentages if the data changes.
Pie slices: 40, 25, 20 and 15%conic-gradient(#6366f1 0 40%, #22d3ee 0 65%, #f59e0b 0 85%, #e2e8f0 0)
The pie's background on its own. On a round element it reads as a chart.

Hard edges in conic gradients can look slightly jagged along the slice lines in some browsers. If it bothers you, leave a fraction of a degree between stops, such as #6366f1 0 39.8%, #22d3ee 40.2% 65%, so the edge gets a hair of blending.

Colour wheels with hue interpolation

A colour wheel usually needs six or seven stops. With interpolation methods you can ask the browser to travel the hue circle itself. longer hue takes the long way round between two hues, and when both stops are the same colour, the long way is the whole circle, so two reds make a full spectrum.

css
.wheel {
  border-radius: 50%;
  background: conic-gradient(in hsl longer hue, #ff0000, #ff0000);
}
One colour, twice, and a full rainbow in between. OKLCH gradients explain shorter and longer hue.

Metallic sheen and highlights

Real brushed metal and polished discs catch light in angular bands, which is exactly what a conic gradient draws. Alternate a few light and dark greys, uneven in spacing, and the surface reads as metal. Layered at low opacity over a colour, the same trick adds a sheen to buttons and cards; see gradient buttons for a worked example.

Uneven light and dark bands swept around the centre read as polished metal.

Repeating conic gradients for patterns

repeating-conic-gradient() repeats its stop list around the turn. Short, hard-edged stops give starbursts. Paired with background-size, a two-colour quarter pattern tiles into a checkerboard, a pattern that is otherwise awkward to draw with gradients. More in CSS patterns.

Short hard stops repeated all the way round.
css
.checkerboard {
  background: repeating-conic-gradient(#e2e8f0 0 25%, #ffffff 0 50%) 0 0 / 32px 32px;
}
A 16 pixel checkerboard: the classic transparency grid behind image editors.

Questions people ask

What is a conic gradient in CSS?

It is a gradient whose colours change with the angle around a centre point, starting at the top and moving clockwise, written with conic-gradient().

How do I make a pie chart with CSS?

Use hard stops in a conic gradient, such as conic-gradient(#6366f1 0 40%, #22d3ee 0 65%, #e2e8f0 0), on an element with border-radius: 50%. Also put the values in text for screen readers.

How do I rotate a conic gradient?

Add from and an angle as the first argument, for example conic-gradient(from 90deg, ...). The sweep then starts at three o'clock instead of the top.

Why are the edges of my conic gradient jagged?

Hard stops have no blending, and some browsers draw the boundary without smoothing. Leaving a fraction of a degree between neighbouring stops softens it.

Do conic gradients work in all browsers?

Yes, current versions of Chrome, Edge, Safari and Firefox support conic-gradient() and repeating-conic-gradient() without prefixes.

Share this guide

Written by GradientlyVerified Gradiently account

The team behind Gradiently, a design tool built around Marks: living gradients that make everything you design look like yours.

See our profile