Files
courier/app/copy-button.tsx
2026-11-23 13:33:10 +00:00

24 lines
503 B
TypeScript

"use client";
import { useState } from "react";
export function CopyButton({ value, label = "Kopieren" }: { value: string; label?: string }) {
const [copied, setCopied] = useState(false);
async function copy() {
try {
await navigator.clipboard.writeText(value);
setCopied(true);
setTimeout(() => setCopied(false), 2000);
} catch {
setCopied(false);
}
}
return (
<button type="button" className="btn btn-sekundaer btn-klein" onClick={copy}>
{copied ? "Kopiert" : label}
</button>
);
}