import { useState } from "react"; import { Copy, Check } from "lucide-react"; import { Button } from "./button"; import { cn } from "../lib/utils"; function CopyButton({ value, label, className, onCopy, }: { value: string; label?: string; className?: string; /** Fires after a successful copy. Receives nothing — the copied value may be sensitive. */ onCopy?: () => void; }) { const [copied, setCopied] = useState(false); const handleCopy = () => { void navigator.clipboard.writeText(value).then(() => { setCopied(true); onCopy?.(); setTimeout(() => setCopied(false), 1500); }); }; if (label) { return ( ); } return ( ); } export { CopyButton };