diff --git a/docs/components/copy-button.tsx b/docs/components/copy-button.tsx new file mode 100644 index 00000000..01dbd054 --- /dev/null +++ b/docs/components/copy-button.tsx @@ -0,0 +1,64 @@ +"use client"; + +import { useState } from "react"; + +type Props = { + text: string; + className?: string; +}; + +export function CopyButton({ text, className = "" }: Props) { + const [copied, setCopied] = useState(false); + + const onClick = async () => { + try { + await navigator.clipboard.writeText(text); + setCopied(true); + setTimeout(() => setCopied(false), 1500); + } catch { + // Older browsers or denied permission — fail silently + } + }; + + return ( + + ); +}