{
  "schemaVersion": 1,
  "target": "react",
  "name": "spinner",
  "version": "0.1.0",
  "category": "feedback",
  "title": "Spinner",
  "description": "A small loading indicator in four sizes, as a quarter arc or a stepping ring of dots, with an accessible label that can also be shown as text.",
  "tags": [
    "loading",
    "loader",
    "busy",
    "progress",
    "activity",
    "indicator"
  ],
  "requires": {
    "projectTypes": [
      "next",
      "vite-react"
    ],
    "styling": "tailwind-v4"
  },
  "npmDependencies": {},
  "registryDependencies": [],
  "docsPath": "/components/spinner",
  "props": [
    {
      "name": "size",
      "type": "\"xs\" | \"sm\" | \"md\" | \"lg\"",
      "default": "\"sm\"",
      "description": "12, 16, 20, or 24px."
    },
    {
      "name": "variant",
      "type": "\"arc\" | \"dots\"",
      "default": "\"arc\"",
      "description": "arc is the quarter arc on a faint track used by Button; dots is a ring of eight dots whose brightest dot steps around it."
    },
    {
      "name": "label",
      "type": "ReactNode",
      "default": "\"Loading\"",
      "description": "What is loading. Read by screen readers, and shown beside the spinner with showLabel."
    },
    {
      "name": "showLabel",
      "type": "boolean",
      "default": "false",
      "description": "Shows the label as secondary text beside the spinner."
    },
    {
      "name": "decorative",
      "type": "boolean",
      "default": "false",
      "description": "Hides the spinner from assistive technology when the surrounding element already reports that it is busy."
    }
  ],
  "accessibility": [
    "Renders a polite status region (role=\"status\") named by its label text, which is visually hidden unless showLabel is set.",
    "decorative sets aria-hidden for spinners inside elements that already announce busy state, such as a button with aria-busy.",
    "The SVG marks are aria-hidden; only the label is read.",
    "The rotation runs only with motion-safe; under reduced motion both variants render a still frame."
  ],
  "states": [
    "arc",
    "dots",
    "with label",
    "decorative"
  ],
  "files": [
    {
      "path": "ui/spinner.tsx",
      "content": "import type { ComponentProps, ReactNode } from \"react\";\n\nfunction cx(...classes: (string | false | null | undefined)[]) {\n  return classes.filter(Boolean).join(\" \");\n}\n\nconst sizes = {\n  xs: { box: \"size-3\", text: \"text-xs\", gap: \"gap-1.5\" },\n  sm: { box: \"size-4\", text: \"text-sm\", gap: \"gap-2\" },\n  md: { box: \"size-5\", text: \"text-sm\", gap: \"gap-2\" },\n  lg: { box: \"size-6\", text: \"text-[15px]\", gap: \"gap-2.5\" },\n} as const;\n\nexport type SpinnerSize = keyof typeof sizes;\n\nexport interface SpinnerProps extends Omit<ComponentProps<\"span\">, \"children\" | \"role\"> {\n  /** 12, 16, 20, or 24px. */\n  size?: SpinnerSize;\n  /**\n   * `arc` is the quarter arc on a faint track, the same one Button uses while loading.\n   * `dots` is a ring of eight dots whose brightest dot steps around, in the dot language of the agent marks.\n   */\n  variant?: \"arc\" | \"dots\";\n  /** What is loading. Read by screen readers, and shown next to the spinner with `showLabel`. */\n  label?: ReactNode;\n  /** Shows the label as text beside the spinner instead of only to screen readers. */\n  showLabel?: boolean;\n  /**\n   * Hides the spinner from assistive technology, for when the surrounding element already\n   * says it is busy (a button with `aria-busy`, a region with its own status text).\n   */\n  decorative?: boolean;\n}\n\n/**\n * A small loading indicator. It is a polite status region named by `label`, unless `decorative`.\n * The rotation is the one loop DESIGN.md allows; with reduced motion it holds still.\n */\nexport function Spinner({\n  size = \"sm\",\n  variant = \"arc\",\n  label = \"Loading\",\n  showLabel = false,\n  decorative = false,\n  className,\n  ...props\n}: SpinnerProps) {\n  const config = sizes[size];\n  return (\n    <span\n      role={decorative ? undefined : \"status\"}\n      aria-hidden={decorative || undefined}\n      data-variant={variant}\n      className={cx(\n        \"inline-flex shrink-0 items-center align-middle text-zinc-950 dark:text-white\",\n        showLabel && config.gap,\n        className,\n      )}\n      {...props}\n    >\n      {variant === \"dots\" ? <DotsMark className={config.box} /> : <ArcMark className={config.box} />}\n      {decorative ? null : showLabel ? (\n        <span className={cx(\"leading-5 text-zinc-600 dark:text-zinc-400\", config.text)}>{label}</span>\n      ) : (\n        <span className=\"sr-only\">{label}</span>\n      )}\n    </span>\n  );\n}\n\nfunction ArcMark({ className }: { className: string }) {\n  return (\n    <svg aria-hidden=\"true\" viewBox=\"0 0 16 16\" fill=\"none\" className={cx(\"motion-safe:animate-spin\", className)}>\n      <circle cx=\"8\" cy=\"8\" r=\"6\" stroke=\"currentColor\" strokeOpacity=\"0.2\" strokeWidth=\"1.5\" />\n      <path d=\"M14 8a6 6 0 0 0-6-6\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" />\n    </svg>\n  );\n}\n\n// Brightest first, then a fading tail behind it in the direction of travel.\nconst tail = [1, 0.78, 0.6, 0.46, 0.35, 0.27, 0.21, 0.17];\n\nfunction DotsMark({ className }: { className: string }) {\n  return (\n    <svg\n      aria-hidden=\"true\"\n      viewBox=\"0 0 16 16\"\n      fill=\"currentColor\"\n      // Eight discrete steps per turn: the lit dot hops from position to position instead of\n      // smearing, so the ring reads as dots even at 12px.\n      className={cx(\"motion-safe:animate-spin motion-safe:[animation-duration:0.96s] motion-safe:[animation-timing-function:steps(8,end)]\", className)}\n    >\n      {tail.map((opacity, i) => {\n        // Counter-clockwise from the top, so the bright dot leads a clockwise turn.\n        const angle = -Math.PI / 2 - (i * Math.PI) / 4;\n        return (\n          <circle\n            key={i}\n            cx={(8 + Math.cos(angle) * 5.6).toFixed(2)}\n            cy={(8 + Math.sin(angle) * 5.6).toFixed(2)}\n            r={i === 0 ? 1.45 : 1.25}\n            opacity={opacity}\n          />\n        );\n      })}\n    </svg>\n  );\n}\n"
    }
  ],
  "example": {
    "content": "import { Spinner } from \"@/components/shaken/ui/spinner\";\n\nconst sizes = [\"xs\", \"sm\", \"md\", \"lg\"] as const;\n\nexport default function SpinnerExample() {\n  return (\n    <div className=\"grid w-full max-w-md gap-8\">\n      <div className=\"grid grid-cols-[auto_1fr] items-center gap-x-6 gap-y-5\">\n        <span className=\"text-xs font-medium text-zinc-500\">Arc</span>\n        <div className=\"flex items-center gap-5\">\n          {sizes.map((size) => (\n            <Spinner key={size} size={size} label={`Loading, ${size}`} />\n          ))}\n        </div>\n        <span className=\"text-xs font-medium text-zinc-500\">Dots</span>\n        <div className=\"flex items-center gap-5\">\n          {sizes.map((size) => (\n            <Spinner key={size} size={size} variant=\"dots\" label={`Loading, ${size}`} />\n          ))}\n        </div>\n      </div>\n\n      <div className=\"divide-y divide-zinc-950/[0.07] rounded-xl border border-zinc-950/10 dark:divide-white/[0.08] dark:border-white/10\">\n        <div className=\"flex items-center justify-between gap-4 px-4 py-3 text-sm\">\n          <span className=\"text-zinc-950 dark:text-white\">acme/web</span>\n          <Spinner showLabel label=\"Syncing 24 files\" />\n        </div>\n        <div className=\"flex items-center justify-between gap-4 px-4 py-3 text-sm\">\n          <span className=\"text-zinc-950 dark:text-white\">acme/api</span>\n          <Spinner showLabel variant=\"dots\" label=\"Indexing\" />\n        </div>\n      </div>\n    </div>\n  );\n}\n"
  }
}
