{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"stat-cards-goal","type":"registry:component","title":"Stat cards · Goal ring","description":"Progress ring and percentage spring to each logged step; milestones tick and the goal swaps to a done state.","author":"GetUrUI <hello@geturui.dev>","dependencies":["motion","lucide-react"],"registryDependencies":[],"files":[{"path":"registry/geturui/examples/stat-cards/goal.tsx","type":"registry:component","target":"components/examples/stat-cards/goal.tsx","content":"\"use client\";\n\nimport * as React from \"react\";\nimport { AnimatePresence, motion, useReducedMotion, useSpring, useTransform } from \"motion/react\";\nimport { Check, Minus, Plus, Target } from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface GoalRingCardProps {\n  label?: string;\n  /** What one step counts, e.g. \"demos booked\". */\n  unit?: string;\n  defaultValue?: number;\n  goal?: number;\n  /** Deadline caption, e.g. \"Ends Oct 31\". */\n  deadline?: string;\n  /** Checkpoints shown under the ring, as fractions of the goal. */\n  milestones?: number[];\n  onChange?: (value: number) => void;\n  className?: string;\n}\n\nconst focus = \"outline-none focus-visible:shadow-[var(--focus-ring)]\";\nconst R = 52;\nconst C = 2 * Math.PI * R;\n\n/** Goal progress ring: the arc and percentage spring to each new value, milestones tick off, and hitting the goal swaps in a done state. */\nexport function GoalRingCard({\n  label = \"Q4 sales goal\",\n  unit = \"demos booked\",\n  defaultValue = 34,\n  goal = 48,\n  deadline = \"Ends Dec 31\",\n  milestones = [0.25, 0.5, 0.75, 1],\n  onChange,\n  className,\n}: GoalRingCardProps) {\n  const reduce = useReducedMotion() ?? false;\n  const [value, setValue] = React.useState(defaultValue);\n  const pct = Math.min(1, value / goal);\n  const done = value >= goal;\n\n  const mv = useSpring(reduce ? pct : 0, { stiffness: 90, damping: 20 });\n  const offset = useTransform(mv, (v) => C * (1 - v));\n  const label100 = useTransform(mv, (v) => `${Math.round(v * 100)}%`);\n  React.useEffect(() => {\n    if (reduce) mv.jump(pct);\n    else mv.set(pct);\n  }, [pct, reduce, mv]);\n\n  function set(n: number) {\n    const next = Math.max(0, Math.min(goal, n));\n    setValue(next);\n    onChange?.(next);\n  }\n\n  return (\n    <section aria-label={label} className={cn(\"w-full max-w-[340px] rounded-xl border border-border bg-surface-raised p-5 shadow-sm\", className)}>\n      <div className=\"flex items-center justify-between\">\n        <p className=\"inline-flex items-center gap-1.5 text-[13px] font-medium text-ink-muted\">\n          <Target aria-hidden className=\"size-4\" />\n          {label}\n        </p>\n        <span className=\"font-mono text-[11px] text-ink-subtle\">{deadline}</span>\n      </div>\n\n      <div className=\"mt-4 flex items-center gap-5\">\n        <div className=\"relative size-[132px] shrink-0\">\n          <svg viewBox=\"0 0 132 132\" className=\"size-full -rotate-90\" role=\"progressbar\" aria-label={`${label} progress`} aria-valuemin={0} aria-valuemax={goal} aria-valuenow={value} aria-valuetext={`${value} of ${goal} ${unit}`}>\n            <circle cx=\"66\" cy=\"66\" r={R} fill=\"none\" strokeWidth=\"12\" className=\"stroke-surface-sunken\" />\n            <motion.circle cx=\"66\" cy=\"66\" r={R} fill=\"none\" strokeWidth=\"12\" strokeLinecap=\"round\" strokeDasharray={C} style={{ strokeDashoffset: offset }} className=\"stroke-volt\" />\n            {milestones.slice(0, -1).map((m) => {\n              const a = m * 2 * Math.PI;\n              return <circle key={m} cx={66 + R * Math.cos(a)} cy={66 + R * Math.sin(a)} r=\"2\" className={cn(\"transition-colors\", pct >= m ? \"fill-on-volt/40\" : \"fill-ink-subtle/50\")} />;\n            })}\n          </svg>\n          <div className=\"absolute inset-0 grid place-items-center text-center\">\n            <AnimatePresence mode=\"popLayout\" initial={false}>\n              {done ? (\n                <motion.span\n                  key=\"done\"\n                  initial={reduce ? { opacity: 0 } : { scale: 0.3, opacity: 0 }}\n                  animate={{ scale: 1, opacity: 1 }}\n                  exit={{ opacity: 0 }}\n                  transition={{ type: \"spring\", stiffness: 420, damping: 16 }}\n                  className=\"grid size-12 place-items-center rounded-full bg-volt text-on-volt\"\n                >\n                  <Check aria-hidden className=\"size-6\" strokeWidth={3} />\n                </motion.span>\n              ) : (\n                <motion.span key=\"pct\" initial={{ opacity: 0 }} animate={{ opacity: 1 }} exit={{ opacity: 0 }} className=\"font-display text-[28px] font-semibold tracking-[-0.8px] text-ink tabular-nums\">\n                  <motion.span>{label100}</motion.span>\n                </motion.span>\n              )}\n            </AnimatePresence>\n          </div>\n        </div>\n\n        <div className=\"min-w-0\">\n          <p className=\"font-display text-[28px] font-semibold leading-none tracking-[-0.8px] text-ink tabular-nums\">\n            {value}\n            <span className=\"text-base font-medium text-ink-subtle\"> / {goal}</span>\n          </p>\n          <p className=\"mt-1 text-xs text-ink-muted\">{unit}</p>\n          <AnimatePresence mode=\"popLayout\" initial={false}>\n            <motion.p\n              key={done ? \"d\" : \"r\"}\n              initial={{ opacity: 0, filter: \"blur(6px)\" }}\n              animate={{ opacity: 1, filter: \"blur(0px)\" }}\n              exit={{ opacity: 0, filter: \"blur(6px)\" }}\n              className={cn(\"mt-3 text-xs font-medium\", done ? \"text-volt-ink\" : \"text-ink\")}\n            >\n              {done ? \"Goal reached\" : `${goal - value} to go`}\n            </motion.p>\n          </AnimatePresence>\n        </div>\n      </div>\n\n      <ol aria-label=\"Milestones\" className=\"mt-5 grid grid-cols-4 gap-1.5\">\n        {milestones.map((m) => {\n          const hit = pct >= m;\n          return (\n            <li key={m} className=\"text-center\">\n              <span className=\"block h-1 overflow-hidden rounded-full bg-surface-sunken\">\n                <motion.span className=\"block h-full origin-left rounded-full bg-ink\" animate={{ scaleX: hit ? 1 : 0 }} transition={{ type: \"spring\", stiffness: 260, damping: 28 }} />\n              </span>\n              <span className={cn(\"mt-1 block font-mono text-[10.5px]\", hit ? \"text-ink\" : \"text-ink-subtle\")}>\n                {Math.round(m * goal)}\n                <span className=\"sr-only\">{hit ? \" reached\" : \" not reached\"}</span>\n              </span>\n            </li>\n          );\n        })}\n      </ol>\n\n      <div className=\"mt-4 flex items-center gap-2 border-t border-border pt-4\">\n        <motion.button type=\"button\" aria-label=\"Remove one\" whileTap={reduce ? undefined : { scale: 0.92 }} onClick={() => set(value - 1)} disabled={value <= 0} className={cn(\"grid size-9 place-items-center rounded-full border border-border-strong/40 text-ink hover:bg-surface-hover disabled:opacity-40\", focus)}>\n          <Minus aria-hidden className=\"size-4\" />\n        </motion.button>\n        <motion.button type=\"button\" whileTap={reduce ? undefined : { scale: 0.96 }} onClick={() => set(value + 1)} disabled={done} className={cn(\"inline-flex h-9 flex-1 items-center justify-center gap-1.5 rounded-full bg-volt text-[13px] font-semibold text-on-volt disabled:cursor-not-allowed disabled:bg-surface-sunken disabled:text-ink-subtle\", focus)}>\n          <Plus aria-hidden className=\"size-4\" />\n          Log one\n        </motion.button>\n      </div>\n    </section>\n  );\n}\n"},{"path":"LICENSE-geturui.md","type":"registry:file","target":"LICENSE-geturui.md","content":"MIT License\n\nCopyright (c) 2026 geturui.com\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"}],"categories":["examples","stats","kpi","metric","dashboard","sparkline","progress","goal","comparison","analytics"],"meta":{"tier":"free","license":"MIT","docs":"https://geturui.com/docs/stat-cards#goal"}}