{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "stats-4",
  "title": "Count-Up Stats On Scroll",
  "description": "Four-up stat grid whose numbers count up from zero when scrolled into view, each cell pairing an icon with a growth delta badge.",
  "dependencies": [
    "@base-ui/react"
  ],
  "registryDependencies": [
    "badge"
  ],
  "files": [
    {
      "path": "registry/blocks/stats/4/stats-block.tsx",
      "content": "\"use client\"\n\nimport { useEffect, useRef, useState } from \"react\"\nimport { Badge } from \"@/components/ui/badge\"\nimport { cn } from \"@/lib/utils\"\nimport { IconPlaceholder } from \"@/components/icons/icon-placeholder\"\n\ntype IconProps = { className?: string; size?: number | string }\n\ntype IconRenderer = (props: IconProps) => React.ReactNode\n\ntype Metric = {\n  id: string\n  icon: IconRenderer\n  target: number\n  decimals: number\n  prefix: string\n  suffix: string\n  label: string\n  delta: string\n}\n\nconst metrics: Metric[] = [\n  {\n    id: \"uptime\",\n    icon: (p: IconProps) => (\n      <IconPlaceholder\n        lucide=\"Globe\"\n        tabler=\"IconGlobe\"\n        hugeicons=\"GlobalIcon\"\n        phosphor=\"Globe\"\n        remixicon=\"RiGlobalLine\"\n        {...p}\n      />\n    ),\n    target: 99.9,\n    decimals: 1,\n    prefix: \"\",\n    suffix: \"%\",\n    label: \"Service uptime\",\n    delta: \"+0.4%\",\n  },\n  {\n    id: \"users\",\n    icon: (p: IconProps) => (\n      <IconPlaceholder\n        lucide=\"Users\"\n        tabler=\"IconUsersGroup\"\n        hugeicons=\"UserGroupIcon\"\n        phosphor=\"UsersThree\"\n        remixicon=\"RiTeamLine\"\n        {...p}\n      />\n    ),\n    target: 12,\n    decimals: 0,\n    prefix: \"\",\n    suffix: \"k+\",\n    label: \"Active teams\",\n    delta: \"+18%\",\n  },\n  {\n    id: \"rating\",\n    icon: (p: IconProps) => (\n      <IconPlaceholder\n        lucide=\"Star\"\n        tabler=\"IconStar\"\n        hugeicons=\"StarIcon\"\n        phosphor=\"Star\"\n        remixicon=\"RiStarSmileLine\"\n        {...p}\n      />\n    ),\n    target: 4.9,\n    decimals: 1,\n    prefix: \"\",\n    suffix: \"/5\",\n    label: \"Average rating\",\n    delta: \"+0.2\",\n  },\n  {\n    id: \"integrations\",\n    icon: (p: IconProps) => (\n      <IconPlaceholder\n        lucide=\"Clock\"\n        tabler=\"IconClock\"\n        hugeicons=\"TimeIcon\"\n        phosphor=\"Clock\"\n        remixicon=\"RiTimeLine\"\n        {...p}\n      />\n    ),\n    target: 250,\n    decimals: 0,\n    prefix: \"\",\n    suffix: \"+\",\n    label: \"Integrations shipped\",\n    delta: \"+32\",\n  },\n]\n\nfunction formatValue(value: number, metric: Metric) {\n  const fixed = value.toFixed(metric.decimals)\n  return `${metric.prefix}${fixed}${metric.suffix}`\n}\n\nexport default function StatsBlock() {\n  const sectionRef = useRef<HTMLElement | null>(null)\n  const [progress, setProgress] = useState(0)\n\n  useEffect(() => {\n    const node = sectionRef.current\n    if (!node) return\n\n    let frame = 0\n    let started = false\n\n    const animate = (start: number) => {\n      const duration = 1600\n\n      const step = (now: number) => {\n        const elapsed = now - start\n        const linear = Math.min(elapsed / duration, 1)\n        const eased = 1 - Math.pow(1 - linear, 3)\n        setProgress(eased)\n        if (linear < 1) {\n          frame = requestAnimationFrame(step)\n        }\n      }\n\n      frame = requestAnimationFrame(step)\n    }\n\n    const prefersReduced =\n      typeof window !== \"undefined\" &&\n      window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches\n\n    if (prefersReduced) {\n      const id = requestAnimationFrame(() => setProgress(1))\n      return () => cancelAnimationFrame(id)\n    }\n\n    const observer = new IntersectionObserver(\n      (entries) => {\n        for (const entry of entries) {\n          if (entry.isIntersecting && !started) {\n            started = true\n            animate(performance.now())\n            observer.disconnect()\n          }\n        }\n      },\n      { threshold: 0.35 }\n    )\n\n    observer.observe(node)\n\n    return () => {\n      observer.disconnect()\n      if (frame) cancelAnimationFrame(frame)\n    }\n  }, [])\n\n  return (\n    <section\n      ref={sectionRef}\n      className=\"flex w-full items-center justify-center bg-muted/30 px-6 py-16 text-foreground\"\n    >\n      <div className=\"mx-auto w-full max-w-6xl\">\n        <div className=\"mx-auto max-w-2xl text-center\">\n          <Badge variant=\"secondary\" className=\"mb-4\">\n            <IconPlaceholder\n              lucide=\"ArrowUp\"\n              tabler=\"IconArrowUp\"\n              hugeicons=\"ArrowUpIcon\"\n              phosphor=\"ArrowUp\"\n              remixicon=\"RiArrowUpLine\"\n              data-icon=\"inline-start\"\n            />\n            By the Numbers\n          </Badge>\n          <h2 className=\"font-heading text-3xl font-semibold tracking-tight sm:text-4xl\">\n            Numbers teams at Acme trust\n          </h2>\n          <p className=\"mt-3 text-base text-balance text-muted-foreground\">\n            Real performance from a platform built to scale with you, measured\n            and reported every single quarter.\n          </p>\n        </div>\n\n        <dl className=\"mt-12 grid grid-cols-1 gap-px overflow-hidden rounded-xl border border-border bg-border sm:grid-cols-2 md:grid-cols-4\">\n          {metrics.map((metric) => {\n            const Icon = metric.icon\n            const current = metric.target * progress\n            return (\n              <div\n                key={metric.id}\n                className=\"group flex flex-col gap-4 bg-card p-6 transition-colors hover:bg-card/60 sm:p-8\"\n              >\n                <div className=\"flex items-center justify-between\">\n                  <span className=\"flex size-10 items-center justify-center rounded-md bg-muted text-muted-foreground transition-colors group-hover:bg-primary/10 group-hover:text-primary\">\n                    <Icon className=\"size-5\" aria-hidden=\"true\" />\n                  </span>\n                  <Badge\n                    variant=\"outline\"\n                    className=\"border-transparent bg-primary/10 text-primary\"\n                  >\n                    <IconPlaceholder\n                      lucide=\"ArrowUp\"\n                      tabler=\"IconArrowUp\"\n                      hugeicons=\"ArrowUpIcon\"\n                      phosphor=\"ArrowUp\"\n                      remixicon=\"RiArrowUpLine\"\n                      data-icon=\"inline-start\"\n                    />\n                    {metric.delta}\n                  </Badge>\n                </div>\n                <div>\n                  <dd\n                    className={cn(\n                      \"text-4xl font-semibold tracking-tight tabular-nums sm:text-5xl\"\n                    )}\n                  >\n                    {formatValue(current, metric)}\n                  </dd>\n                  <dt className=\"mt-2 text-sm text-muted-foreground\">\n                    {metric.label}\n                  </dt>\n                </div>\n              </div>\n            )\n          })}\n        </dl>\n      </div>\n    </section>\n  )\n}\n",
      "type": "registry:component",
      "target": "components/blocks/stats-4.tsx"
    }
  ],
  "meta": {
    "height": "519px",
    "tier": "free"
  },
  "categories": [
    "stats"
  ],
  "type": "registry:block"
}