{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"stats-section","type":"registry:block","title":"Stats","description":"Four headline numbers that roll in digit by digit, each with a sparkline that draws itself, fills its area and drops an end dot when scrolled into view.","author":"GetUrUI <hello@geturui.dev>","dependencies":["motion","lucide-react"],"registryDependencies":["@geturui/number-ticker"],"files":[{"path":"registry/geturui/blocks/stats-section.tsx","type":"registry:block","target":"components/blocks/stats-section.tsx","content":"\"use client\";\n\nimport * as React from \"react\";\nimport { motion } from \"motion/react\";\nimport { TrendingDown, TrendingUp } from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\nimport { NumberTicker } from \"@/components/ui/number-ticker\";\n\nconst REDUCE = \"(prefers-reduced-motion: reduce)\";\nconst subscribeReduce = (cb: () => void) => {\n  const m = window.matchMedia(REDUCE);\n  m.addEventListener(\"change\", cb);\n  return () => m.removeEventListener(\"change\", cb);\n};\n/** Reduced-motion preference that is false on the server and during hydration, so the first render matches. */\nfunction useReducedMotionSafe() {\n  return React.useSyncExternalStore(subscribeReduce, () => window.matchMedia(REDUCE).matches, () => false);\n}\n\nexport interface Stat {\n  label: string;\n  value: number;\n  prefix?: string;\n  suffix?: string;\n  decimals?: number;\n  description?: string;\n  /** Data points for the sparkline, oldest first (at least 2). */\n  trend?: number[];\n  /** Change label, e.g. \"+18% QoQ\". */\n  delta?: string;\n  /** Whether the change is good or bad news; colours the delta. */\n  deltaDirection?: \"up\" | \"down\";\n}\n\nexport interface StatsSectionProps {\n  eyebrow?: string;\n  heading?: string;\n  subheading?: string;\n  stats?: Stat[];\n  className?: string;\n}\n\nconst W = 120;\nconst H = 40;\nconst PAD = 3;\n\nfunction sparkPath(points: number[]) {\n  const min = Math.min(...points);\n  const max = Math.max(...points);\n  const span = max - min || 1;\n  const xy = points.map((p, i) => [PAD + (i / (points.length - 1)) * (W - PAD * 2), H - PAD - ((p - min) / span) * (H - PAD * 2)] as const);\n  let d = `M ${xy[0][0].toFixed(2)} ${xy[0][1].toFixed(2)}`;\n  for (let i = 0; i < xy.length - 1; i++) {\n    const p0 = xy[i - 1] ?? xy[i];\n    const p1 = xy[i];\n    const p2 = xy[i + 1];\n    const p3 = xy[i + 2] ?? p2;\n    const c1x = p1[0] + (p2[0] - p0[0]) / 6;\n    const c1y = p1[1] + (p2[1] - p0[1]) / 6;\n    const c2x = p2[0] - (p3[0] - p1[0]) / 6;\n    const c2y = p2[1] - (p3[1] - p1[1]) / 6;\n    d += ` C ${c1x.toFixed(2)} ${c1y.toFixed(2)}, ${c2x.toFixed(2)} ${c2y.toFixed(2)}, ${p2[0].toFixed(2)} ${p2[1].toFixed(2)}`;\n  }\n  const last = xy[xy.length - 1];\n  return { line: d, area: `${d} L ${last[0].toFixed(2)} ${H} L ${xy[0][0].toFixed(2)} ${H} Z`, end: last };\n}\n\nfunction Sparkline({ points, delay, tone }: { points: number[]; delay: number; tone: \"volt\" | \"danger\" }) {\n  const reduce = useReducedMotionSafe();\n  const raw = React.useId();\n  const id = `spark-${raw.replace(/[^a-zA-Z0-9_-]/g, \"\")}`;\n  const { line, area, end } = React.useMemo(() => sparkPath(points), [points]);\n  const color = tone === \"volt\" ? \"var(--volt-ink)\" : \"var(--danger)\";\n  return (\n    <div aria-hidden className=\"relative h-10 w-full\">\n      <svg viewBox={`0 0 ${W} ${H}`} className=\"absolute inset-0 h-full w-full overflow-visible\" preserveAspectRatio=\"none\">\n        <defs>\n          <linearGradient id={id} x1=\"0\" x2=\"0\" y1=\"0\" y2=\"1\">\n            <stop offset=\"0%\" style={{ stopColor: color, stopOpacity: 0.28 }} />\n            <stop offset=\"100%\" style={{ stopColor: color, stopOpacity: 0 }} />\n          </linearGradient>\n        </defs>\n        <motion.path\n          d={area}\n          fill={`url(#${id})`}\n          initial={{ opacity: 0 }}\n          whileInView={{ opacity: 1 }}\n          viewport={{ once: true }}\n          transition={{ duration: 0.8, delay: delay + (reduce ? 0 : 0.7) }}\n        />\n        <motion.path\n          d={line}\n          fill=\"none\"\n          stroke={color}\n          strokeWidth={2}\n          strokeLinecap=\"round\"\n          strokeLinejoin=\"round\"\n          vectorEffect=\"non-scaling-stroke\"\n          initial={reduce ? { opacity: 0 } : { pathLength: 0, opacity: 0 }}\n          whileInView={reduce ? { opacity: 1 } : { pathLength: 1, opacity: 1 }}\n          viewport={{ once: true }}\n          transition={{ pathLength: { duration: 1.1, ease: [0.22, 1, 0.36, 1], delay }, opacity: { duration: 0.2, delay } }}\n        />\n      </svg>\n      <motion.span\n        className=\"absolute size-1.5 -translate-x-1/2 -translate-y-1/2 rounded-full\"\n        style={{ left: `${(end[0] / W) * 100}%`, top: `${(end[1] / H) * 100}%`, background: color, boxShadow: `0 0 0 3px var(--surface)` }}\n        initial={{ scale: 0, opacity: 0 }}\n        whileInView={{ scale: 1, opacity: 1 }}\n        viewport={{ once: true }}\n        transition={{ type: \"spring\", stiffness: 500, damping: 18, delay: delay + (reduce ? 0 : 1) }}\n      />\n    </div>\n  );\n}\n\nconst DEFAULT_STATS: Stat[] = [\n  { label: \"Weekly installs\", value: 48210, description: \"Across npm and the CLI\", trend: [18, 22, 21, 27, 31, 30, 38, 44, 48], delta: \"+18% MoM\", deltaDirection: \"up\" },\n  { label: \"Components\", value: 214, description: \"Free and Pro, all typed\", trend: [120, 128, 140, 151, 160, 176, 190, 204, 214], delta: \"+12 this week\", deltaDirection: \"up\" },\n  { label: \"Median bundle\", value: 2.4, suffix: \" kB\", decimals: 1, description: \"Per component, gzipped\", trend: [3.4, 3.2, 3.1, 2.9, 2.9, 2.7, 2.6, 2.5, 2.4], delta: \"−0.3 kB\", deltaDirection: \"up\" },\n  { label: \"Lighthouse a11y\", value: 100, description: \"On every docs page\", trend: [92, 94, 95, 95, 97, 98, 98, 100, 100], delta: \"Perfect score\", deltaDirection: \"up\" },\n];\n\n/** Four headline numbers that roll in digit by digit, each with a sparkline that draws itself when scrolled into view. */\nexport function StatsSection({\n  eyebrow = \"By the numbers\",\n  heading = \"Built in public, measured every week\",\n  subheading = \"Numbers from the last 30 days across the GetUrUI registry.\",\n  stats = DEFAULT_STATS,\n  className,\n}: StatsSectionProps) {\n  return (\n    <section className={cn(\"@container w-full px-4 py-16 sm:px-6 sm:py-24\", className)}>\n      <div className=\"mx-auto grid max-w-6xl gap-10\">\n        {(heading || eyebrow) && (\n          <header className=\"grid max-w-2xl gap-3\">\n            {eyebrow && <span className=\"text-[13px] font-semibold uppercase tracking-[1px] text-volt-ink\">{eyebrow}</span>}\n            {heading && <h2 className=\"text-balance font-display text-3xl font-semibold tracking-[-0.8px] text-ink @xl:text-[40px] @xl:leading-[1.1]\">{heading}</h2>}\n            {subheading && <p className=\"text-balance text-base leading-7 text-ink-muted\">{subheading}</p>}\n          </header>\n        )}\n        <dl className=\"grid grid-cols-1 gap-px overflow-hidden rounded-lg border border-border bg-border @xl:grid-cols-2 @4xl:grid-cols-4\">\n          {stats.map((s, i) => {\n            const good = (s.deltaDirection ?? \"up\") === \"up\";\n            return (\n              <div key={s.label} className=\"flex flex-col gap-4 bg-surface p-6\">\n                <dt className=\"text-[13px] font-medium text-ink-muted\">{s.label}</dt>\n                <dd className=\"grid gap-4\">\n                  <NumberTicker\n                    value={s.value}\n                    prefix={s.prefix}\n                    suffix={s.suffix}\n                    decimals={s.decimals}\n                    className=\"font-display text-[40px] font-semibold tracking-[-1.2px] text-ink\"\n                  />\n                  {s.trend && s.trend.length > 1 && <Sparkline points={s.trend} delay={0.15 + i * 0.12} tone={good ? \"volt\" : \"danger\"} />}\n                  <div className=\"flex flex-wrap items-center justify-between gap-2 text-[12.5px]\">\n                    {s.description && <span className=\"text-ink-subtle\">{s.description}</span>}\n                    {s.delta && (\n                      <span className={cn(\"inline-flex items-center gap-1 font-medium\", good ? \"text-success\" : \"text-danger\")}>\n                        {good ? <TrendingUp className=\"size-3.5\" aria-hidden /> : <TrendingDown className=\"size-3.5\" aria-hidden />}\n                        {s.delta}\n                      </span>\n                    )}\n                  </div>\n                </dd>\n              </div>\n            );\n          })}\n        </dl>\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":["blocks","stats","metrics","numbers","sparkline","kpi","social proof"],"meta":{"tier":"free","license":"MIT","docs":"https://geturui.com/docs/stats-section"}}