shadimage
Shadcn Chatbot Kit
uicopy-buttonsource: ok · refreshed

Copy Button

npx shadcn add "https://shadcn-chatbot-kit.vercel.app/r/copy-button.json"
free

No selection tags yet — empty means no evidence, not lack of support.

Dependencies

Bundle weight · light

Registry dependencies

buttonhttps://shadcn-chatbot-kit.vercel.app/r/use-copy-to-clipboard.json

Files1 · source cached 10/8/2026, 6:15:45 AM

ui/copy-button.tsx
"use client"

import { Check, Copy } from "lucide-react"

import { cn } from "@/lib/utils"
import { useCopyToClipboard } from "@/registry/default/hooks/use-copy-to-clipboard"
import { Button } from "@/registry/default/ui/button"

type CopyButtonProps = {
  content: string
  copyMessage?: string
}

export function CopyButton({ content, copyMessage }: CopyButtonProps) {
  const { isCopied, handleCopy } = useCopyToClipboard({
    text: content,
    copyMessage,
  })

  return (
    <Button
      variant="ghost"
      size="icon"
      className="relative h-6 w-6"
      aria-label="Copy to clipboard"
      onClick={handleCopy}
    >
      <div className="absolute inset-0 flex items-center justify-center">
        <Check
          className={cn(
            "h-4 w-4 transition-transform ease-in-out",
            isCopied ? "scale-100" : "scale-0"
          )}
        />
      </div>
      <Copy
        className={cn(
          "h-4 w-4 transition-transform ease-in-out",
          isCopied ? "scale-0" : "scale-100"
        )}
      />
    </Button>
  )
}

More from Shadcn Chatbot Kit

Browse all components in this library →