{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"copy-button","type":"registry:ui","title":"Copy Button","description":"Icon button that copies a value to the clipboard and morphs its glyph into a check with a scale-and-blur swap.","author":"GetUrUI <hello@geturui.dev>","dependencies":["motion","lucide-react"],"registryDependencies":[],"files":[{"path":"registry/geturui/ui/copy-button.tsx","type":"registry:ui","target":"components/ui/copy-button.tsx","content":"\"use client\";\n\nimport * as React from \"react\";\nimport { AnimatePresence, motion } from \"motion/react\";\nimport { Check, Copy } from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface CopyButtonProps {\n  value: string;\n  label?: string;\n  /** Called after each click; `copied` is false when the browser blocked the clipboard. */\n  onCopy?: (value: string, copied: boolean) => void;\n  className?: string;\n}\n\n/** Copies `value`; the glyph morphs into a check (scale + blur) for 1.6s. */\nexport function CopyButton({ value, label = \"Copy\", onCopy, className }: CopyButtonProps) {\n  const [copied, setCopied] = React.useState(false);\n  const t = React.useRef<ReturnType<typeof setTimeout> | null>(null);\n  React.useEffect(() => () => {\n    if (t.current) clearTimeout(t.current);\n  }, []);\n\n  async function copy() {\n    let ok = true;\n    try {\n      await navigator.clipboard.writeText(value);\n    } catch {\n      ok = false; /* clipboard blocked — still show feedback */\n    }\n    setCopied(true);\n    onCopy?.(value, ok);\n    if (t.current) clearTimeout(t.current);\n    t.current = setTimeout(() => setCopied(false), 1600);\n  }\n\n  return (\n    <motion.button\n      type=\"button\"\n      whileTap={{ scale: 0.9 }}\n      onClick={copy}\n      aria-label={copied ? \"Copied\" : label}\n      className={cn(\n        \"relative inline-grid size-8 shrink-0 place-items-center rounded-[10px] text-ink-muted outline-none transition-colors hover:bg-surface-hover hover:text-ink focus-visible:shadow-[var(--focus-ring)]\",\n        className,\n      )}\n    >\n      <AnimatePresence mode=\"popLayout\" initial={false}>\n        <motion.span\n          key={copied ? \"check\" : \"copy\"}\n          initial={{ opacity: 0, scale: 0.4, filter: \"blur(4px)\" }}\n          animate={{ opacity: 1, scale: 1, filter: \"blur(0px)\" }}\n          exit={{ opacity: 0, scale: 0.4, filter: \"blur(4px)\" }}\n          transition={{ type: \"spring\", stiffness: 500, damping: 25 }}\n          className=\"col-start-1 row-start-1\"\n        >\n          {copied ? <Check className=\"size-4 text-success\" strokeWidth={2.25} /> : <Copy className=\"size-4\" />}\n        </motion.span>\n      </AnimatePresence>\n    </motion.button>\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":["components","copy","clipboard","code","install","icon button"],"meta":{"tier":"free","license":"MIT","docs":"https://geturui.com/docs/copy-button"}}