{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "copy-button",
  "title": "Copy Button",
  "author": "VenusUI",
  "description": "Copies text to the clipboard and confirms with a check mark and a screen reader message.",
  "dependencies": [
    "lucide-react"
  ],
  "files": [
    {
      "path": "registry/default/ui/copy-button.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { Check, Copy } from \"lucide-react\"\n\nimport { cn } from \"@/lib/utils\"\n\ninterface CopyButtonProps extends Omit<React.ComponentProps<\"button\">, \"value\" | \"onCopy\"> {\n  /** Text to copy. */\n  value: string\n  /** Milliseconds the \"copied\" state is shown. */\n  timeout?: number\n  /** Called after a successful copy. */\n  onCopy?: (value: string) => void\n}\n\n/**\n * Copies `value` to the clipboard and confirms with a check mark. The result\n * (\"Copied\" or \"Copy failed\") is announced to screen readers. Pass children\n * for a text button, or none for an icon button with an `aria-label`.\n */\nfunction CopyButton({ value, timeout = 2000, onCopy, className, children, type = \"button\", ...props }: CopyButtonProps) {\n  const [state, setState] = React.useState<\"idle\" | \"copied\" | \"failed\">(\"idle\")\n\n  React.useEffect(() => {\n    if (state === \"idle\") return\n    const timer = setTimeout(() => setState(\"idle\"), timeout)\n    return () => clearTimeout(timer)\n  }, [state, timeout])\n\n  async function copy() {\n    try {\n      await navigator.clipboard.writeText(value)\n      setState(\"copied\")\n      onCopy?.(value)\n    } catch {\n      setState(\"failed\")\n    }\n  }\n\n  return (\n    <button\n      type={type}\n      data-slot=\"copy-button\"\n      data-state={state}\n      onClick={copy}\n      className={cn(\n        \"inline-flex h-8 min-w-8 items-center justify-center gap-1.5 rounded-md border bg-background px-2 text-sm font-medium outline-none\",\n        \"transition-colors hover:bg-muted focus-visible:ring-3 focus-visible:ring-ring/50 [&_svg]:size-4\",\n        className\n      )}\n      {...props}\n    >\n      {state === \"copied\" ? <Check aria-hidden=\"true\" /> : <Copy aria-hidden=\"true\" />}\n      {children}\n      <span className=\"sr-only\" aria-live=\"polite\">\n        {state === \"copied\" ? \"Copied\" : state === \"failed\" ? \"Copy failed\" : \"\"}\n      </span>\n    </button>\n  )\n}\n\nexport { CopyButton, type CopyButtonProps }\n",
      "type": "registry:ui"
    }
  ],
  "meta": {
    "version": "0.1.0"
  },
  "categories": [
    "buttons",
    "interactive"
  ],
  "type": "registry:ui"
}