{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "stat",
  "type": "registry:ui",
  "title": "Stat",
  "description": "A number tile: a label, a value, an optional change with its direction, and a slot for a sparkline.",
  "categories": [
    "ui"
  ],
  "dependencies": [
    "lucide-react"
  ],
  "registryDependencies": [
    "@rivier-ui/theme",
    "@rivier-ui/cn"
  ],
  "files": [
    {
      "path": "registry/ui/stat.tsx",
      "type": "registry:ui",
      "target": "components/ui/stat.tsx",
      "content": "/**\n * @name stat\n * @category ui\n * @description A number tile: a label, a value, an optional change with its direction, and a slot for a sparkline.\n * @when A headline figure on a dashboard or in a bento cell. Pass `change` as a magnitude (\"12%\"): the sign and the arrow are added from `direction`. For several figures compared over time use a chart or a table.\n * @example\n * <Stat label=\"Revenue\" value=\"€48,200\" change=\"12%\" direction=\"up\" changeLabel=\"vs last month\" />\n * <Stat label=\"Churn\" value=\"2.1%\" change=\"0.4 pts\" direction=\"up\" tone=\"negative\" />\n * <Stat\n *   label=\"Uptime\"\n *   value=\"99.98%\"\n *   chart={\n *     <svg viewBox=\"0 0 100 24\" preserveAspectRatio=\"none\" className=\"h-8 w-full\" aria-hidden=\"true\">\n *       <polyline points=\"0,18 20,14 40,16 60,8 80,10 100,4\" fill=\"none\" strokeWidth=\"1.5\" className=\"stroke-chart-1\" />\n *     </svg>\n *   }\n * />\n */\nimport { ArrowDownRight, ArrowUpRight, Minus } from \"lucide-react\";\nimport type { ComponentProps, ReactNode } from \"react\";\nimport { cn } from \"@/lib/cn\";\n\nexport type StatDirection = \"up\" | \"down\" | \"flat\";\nexport type StatTone = \"positive\" | \"negative\" | \"neutral\";\n\nexport type StatProps = ComponentProps<\"div\"> & {\n  label: ReactNode;\n  value: ReactNode;\n  /** The size of the change, without a sign: \"12%\", \"340\". */\n  change?: ReactNode;\n  /** Which way the figure moved. Shown by an arrow and a sign (+ or −), never by colour alone. Defaults to \"flat\". */\n  direction?: StatDirection;\n  /** Whether the move is good news. Defaults to up = positive, down = negative; set it when up is bad (churn, cost). */\n  tone?: StatTone;\n  /** A short note after the change: \"vs last month\". */\n  changeLabel?: ReactNode;\n  /** A sparkline or other small chart, placed under the figures. */\n  chart?: ReactNode;\n};\n\nconst ICON: Record<StatDirection, typeof Minus> = { up: ArrowUpRight, down: ArrowDownRight, flat: Minus };\nconst SIGN: Record<StatDirection, string> = { up: \"+\", down: \"−\", flat: \"\" };\nconst TONE: Record<StatTone, string> = { positive: \"text-success\", negative: \"text-destructive\", neutral: \"text-foreground\" };\n\nexport function Stat({ className, label, value, change, direction = \"flat\", tone, changeLabel, chart, children, ...props }: StatProps) {\n  const Icon = ICON[direction];\n  const mood: StatTone = tone ?? (direction === \"up\" ? \"positive\" : direction === \"down\" ? \"negative\" : \"neutral\");\n  return (\n    <div data-slot=\"stat\" className={cn(\"flex min-w-0 flex-col gap-2 rounded-surface border bg-card p-5 text-card-foreground\", className)} {...props}>\n      <p data-slot=\"stat-label\" className=\"text-sm text-muted-foreground\">\n        {label}\n      </p>\n      <p data-slot=\"stat-value\" className=\"text-3xl leading-none font-medium tracking-tight tabular-nums\">\n        {value}\n      </p>\n      {change !== undefined && change !== null ? (\n        <p data-slot=\"stat-change\" data-direction={direction} className=\"flex flex-wrap items-center gap-x-1.5 gap-y-1 text-sm\">\n          <span className={cn(\"inline-flex items-center gap-1 font-medium tabular-nums\", TONE[mood])}>\n            <Icon aria-hidden=\"true\" strokeWidth={1.5} className=\"size-4 shrink-0\" />\n            <span>\n              {SIGN[direction]}\n              {change}\n            </span>\n          </span>\n          {changeLabel ? <span className=\"text-muted-foreground\">{changeLabel}</span> : null}\n        </p>\n      ) : null}\n      {chart ? (\n        <div data-slot=\"stat-chart\" className=\"mt-auto min-w-0 pt-2\">\n          {chart}\n        </div>\n      ) : null}\n      {children}\n    </div>\n  );\n}\n"
    }
  ],
  "meta": {
    "category": "ui",
    "when": "A headline figure on a dashboard or in a bento cell. Pass `change` as a magnitude (\"12%\"): the sign and the arrow are added from `direction`. For several figures compared over time use a chart or a table.",
    "example": "<Stat label=\"Revenue\" value=\"€48,200\" change=\"12%\" direction=\"up\" changeLabel=\"vs last month\" />\n<Stat label=\"Churn\" value=\"2.1%\" change=\"0.4 pts\" direction=\"up\" tone=\"negative\" />\n<Stat\n  label=\"Uptime\"\n  value=\"99.98%\"\n  chart={\n    <svg viewBox=\"0 0 100 24\" preserveAspectRatio=\"none\" className=\"h-8 w-full\" aria-hidden=\"true\">\n      <polyline points=\"0,18 20,14 40,16 60,8 80,10 100,4\" fill=\"none\" strokeWidth=\"1.5\" className=\"stroke-chart-1\" />\n    </svg>\n  }\n/>",
    "client": false
  }
}
