{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "circular-progress",
  "title": "Circular progress",
  "description": "SVG ring or 270° gauge whose arc springs to the value via stroke-dashoffset, with a rolling percentage or custom label in the center.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://goodui.dev/r/goodui-motion.json",
    "https://goodui.dev/r/number-flow.json"
  ],
  "files": [
    {
      "path": "registry/components/numbers/circular-progress.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { motion, useReducedMotion } from \"motion/react\"\nimport { cn } from \"@/lib/utils\"\nimport { NumberFlow } from \"@/components/goodui/number-flow\"\nimport { spring } from \"@/lib/goodui-motion\"\n\nexport type CircularProgressProps = Omit<React.ComponentProps<\"div\">, \"children\"> & {\n  /** Current value on the 0 to max scale; the arc springs to it. */\n  value: number\n  /** Value that fills the whole ring or gauge. */\n  max?: number\n  /** Diameter in px. */\n  size?: number\n  /** Ring thickness in px. Defaults to 9% of the size. */\n  strokeWidth?: number\n  /** \"ring\" is a full circle, \"gauge\" is a 270° arc open at the bottom. */\n  variant?: \"ring\" | \"gauge\"\n  /** Center content. Defaults to the rolling percentage. Pass null to hide it. */\n  label?: React.ReactNode\n  /** Small line under the center label. */\n  sublabel?: React.ReactNode\n  /** Classes for the arc; it is drawn with currentColor, e.g. \"text-emerald-500\". */\n  indicatorClassName?: string\n  /** Classes for the track; drawn with currentColor. */\n  trackClassName?: string\n  /** Accessible name for the progress bar. */\n  \"aria-label\"?: string\n}\n\n/** SVG ring or 270° gauge whose arc springs to the value, with a rolling percentage in the middle. */\nexport function CircularProgress({\n  value,\n  max = 100,\n  size = 120,\n  strokeWidth,\n  variant = \"ring\",\n  label,\n  sublabel,\n  indicatorClassName,\n  trackClassName,\n  className,\n  style,\n  \"aria-label\": ariaLabel = \"Progress\",\n  ...props\n}: CircularProgressProps) {\n  const reduce = useReducedMotion() ?? false\n  const ratio = max > 0 ? Math.min(Math.max(value / max, 0), 1) : 0\n  const stroke = strokeWidth ?? Math.max(3, Math.round(size * 0.09))\n  const r = (size - stroke) / 2\n  const c = 2 * Math.PI * r\n  const gauge = variant === \"gauge\"\n  const arc = gauge ? c * 0.75 : c\n  // Ring starts at 12 o'clock; the gauge starts at 7:30 so its gap sits at the bottom.\n  const rotate = gauge ? 135 : -90\n  const center = size / 2\n\n  const content =\n    label === undefined ? (\n      <NumberFlow value={ratio} format={{ style: \"percent\", maximumFractionDigits: 0 }} className=\"font-semibold tracking-tight\" />\n    ) : (\n      label\n    )\n\n  return (\n    <div\n      role=\"progressbar\"\n      aria-label={ariaLabel}\n      aria-valuemin={0}\n      aria-valuemax={max}\n      aria-valuenow={Math.min(Math.max(value, 0), max)}\n      aria-valuetext={`${Math.round(ratio * 100)}%`}\n      className={cn(\"relative inline-grid shrink-0 place-items-center\", className)}\n      style={{ width: size, height: size, ...style }}\n      {...props}\n    >\n      <svg width={size} height={size} viewBox={`0 0 ${size} ${size}`} className=\"absolute inset-0 overflow-visible\" aria-hidden=\"true\">\n        <g transform={`rotate(${rotate} ${center} ${center})`}>\n          <circle\n            cx={center}\n            cy={center}\n            r={r}\n            fill=\"none\"\n            stroke=\"currentColor\"\n            strokeWidth={stroke}\n            strokeLinecap=\"round\"\n            strokeDasharray={`${arc} ${c}`}\n            className={cn(\"text-muted\", trackClassName)}\n          />\n          <motion.circle\n            cx={center}\n            cy={center}\n            r={r}\n            fill=\"none\"\n            stroke=\"currentColor\"\n            strokeWidth={stroke}\n            strokeLinecap=\"round\"\n            strokeDasharray={`${arc} ${c}`}\n            className={cn(\"text-primary\", indicatorClassName)}\n            initial={{ strokeDashoffset: arc, opacity: 0 }}\n            // A round cap still paints a dot at 0, so the arc fades out instead.\n            animate={{ strokeDashoffset: arc * (1 - ratio), opacity: ratio > 0 ? 1 : 0 }}\n            transition={\n              reduce\n                ? { duration: 0 }\n                : { strokeDashoffset: spring.morph, opacity: { duration: 0.15 } }\n            }\n          />\n        </g>\n      </svg>\n      {content !== null && (\n        // aria-valuetext carries the value; pass your own aria-valuetext when the label says more.\n        <div aria-hidden=\"true\" className=\"relative flex flex-col items-center leading-none\" style={{ fontSize: Math.max(11, size * 0.2), marginTop: gauge ? size * 0.04 : 0 }}>\n          <div>{content}</div>\n          {sublabel && (\n            <div className=\"mt-1 text-muted-foreground\" style={{ fontSize: Math.max(10, size * 0.09) }}>\n              {sublabel}\n            </div>\n          )}\n        </div>\n      )}\n    </div>\n  )\n}\n",
      "type": "registry:component",
      "target": "components/goodui/circular-progress.tsx"
    }
  ],
  "categories": [
    "components",
    "numbers"
  ],
  "type": "registry:component"
}
