CSS conic gradient: how it works
A conic-gradient turns the colors around a center point, like the hands of a clock, instead of moving them away from it. The stops are positions on the circle, from 0% to 100% (360 degrees), starting at the top and going clockwise. Smooth stops draw a color wheel; two stops in the same position draw a hard edge, which is how pie charts, loading rings and dials are made with a single element and no SVG. This page opens the generator on the "wheel" preset.
A real result: the color wheel
background: conic-gradient(from 0deg at 50% 50%, #ef4444 0%, #f59e0b 20%, #22c55e 40%, #3b82f6 60%, #a855f7 80%, #ef4444 100%);bg-[conic-gradient(from_0deg_at_50%_50%,_#ef4444_0%,_#f59e0b_20%,_#22c55e_40%,_#3b82f6_60%,_#a855f7_80%,_#ef4444_100%)]The first and the last color are the same, so the wheel closes without a seam. Add border-radius: 50% to make it a disc.
A pie chart with hard stops
Each slice is a color from its start to its end, and the next slice starts where the previous one ends. Three slices of 40%, 35% and 25%:
background: conic-gradient(from 0deg at 50% 50%, #3b82f6 0%, #3b82f6 40%, #ffb224 40%, #ffb224 75%, #22c55e 75%, #22c55e 100%);| Slice | Share | Stops | Angle |
|---|---|---|---|
| A | 40% | 0% → 40% | 144° |
| B | 35% | 40% → 75% | 126° |
| C | 25% | 75% → 100% | 90° |
A percentage p becomes p × 3.6 degrees; you can write either unit.
Where the first color starts
The "from" angle rotates the whole gradient. The same pie at four starting angles:
| From | CSS |
|---|---|
| 0deg | conic-gradient(from 0deg at 50% 50%, #3b82f6 0%, #3b82f6 40%, #ffb224 40%, #ffb224 75%, #22c55e 75%, #22c55e 100%) |
| 90deg | conic-gradient(from 90deg at 50% 50%, #3b82f6 0%, #3b82f6 40%, #ffb224 40%, #ffb224 75%, #22c55e 75%, #22c55e 100%) |
| 180deg | conic-gradient(from 180deg at 50% 50%, #3b82f6 0%, #3b82f6 40%, #ffb224 40%, #ffb224 75%, #22c55e 75%, #22c55e 100%) |
| 270deg | conic-gradient(from 270deg at 50% 50%, #3b82f6 0%, #3b82f6 40%, #ffb224 40%, #ffb224 75%, #22c55e 75%, #22c55e 100%) |
Common mistakes
- Using a conic gradient for data that matters without a text alternative: it is a picture. Give the element role="img" and an aria-label that says the values, or show a table.
- Slices that do not add up to 100%: the gap at the end takes the last color, so check that the final stop is 100%.
- Visible jaggies on the hard edges between slices: a slightly overlapping stop (40% and 40.2%) softens them.
How to use the generator
- Keep the conic type and the "wheel" preset, or set the stops of your slices.
- Set the starting angle and the center.
- Copy the CSS or the Tailwind class.
Frequently asked questions
How do I make a pie chart with CSS?
A conic-gradient with two stops per slice (the end of one and the start of the next in the same position) and border-radius: 50%. No JavaScript or SVG is needed.
Which browsers support conic-gradient?
All current versions of Chrome, Edge, Firefox and Safari. Very old browsers ignore the declaration, so put a solid background-color before it as a fallback.
Can I make a donut chart?
Yes: put a smaller element (or a radial-gradient mask) in the middle, or use mask with a radial-gradient that cuts out the center.