{
  "id": "donut-chart",
  "name": "Donut Chart",
  "category": "gradients",
  "tags": [
    "conic-gradient",
    "pie chart",
    "data",
    "legend",
    "mask"
  ],
  "description": "A donut chart with a legend, drawn with one conic gradient and a radial mask, no SVG or JavaScript.",
  "url": "https://copy-css.com/snippets/donut-chart",
  "markdown": "https://copy-css.com/snippets/donut-chart.md",
  "html": "<figure class=\"donut-chart\">\n  <div class=\"donut-chart-ring\" role=\"img\" aria-label=\"Traffic sources: search 45%, social 30%, direct 25%\"></div>\n  <figcaption>\n    <ul class=\"donut-chart-legend\">\n      <li>Search 45%</li>\n      <li>Social 30%</li>\n      <li>Direct 25%</li>\n    </ul>\n  </figcaption>\n</figure>",
  "css": ".donut-chart {\n  /* Segment sizes; the last one fills the rest */\n  --a: 45%;\n  --b: 30%;\n  display: flex;\n  flex-wrap: wrap;\n  align-items: center;\n  justify-content: center;\n  gap: 20px;\n  margin: 0;\n  font: 500 14px/1.2 system-ui, sans-serif;\n  color: #27272a;\n}\n\n.donut-chart-ring {\n  width: 120px;\n  aspect-ratio: 1;\n  border-radius: 50%;\n  background: conic-gradient(\n    #6366f1 0 var(--a),\n    #ec4899 0 calc(var(--a) + var(--b)),\n    #f59e0b 0\n  );\n  -webkit-mask: radial-gradient(farthest-side, #0000 58%, #000 59%);\n  mask: radial-gradient(farthest-side, #0000 58%, #000 59%);\n}\n\n.donut-chart-legend {\n  display: grid;\n  gap: 10px;\n  margin: 0;\n  padding: 0;\n  list-style: none;\n}\n\n.donut-chart-legend li {\n  display: flex;\n  align-items: center;\n  gap: 8px;\n}\n\n.donut-chart-legend li::before {\n  content: \"\";\n  width: 12px;\n  height: 12px;\n  border-radius: 3px;\n  background: #6366f1;\n}\n\n.donut-chart-legend li:nth-child(2)::before {\n  background: #ec4899;\n}\n\n.donut-chart-legend li:nth-child(3)::before {\n  background: #f59e0b;\n}",
  "features": [
    "radial gradients",
    "conic gradients",
    "masks",
    "CSS Grid",
    "Flexbox",
    "aspect-ratio",
    "custom properties"
  ],
  "customProperties": [
    {
      "name": "--a",
      "value": "45%"
    },
    {
      "name": "--b",
      "value": "30%"
    }
  ]
}
