mirror of
https://github.com/block/buzz.git
synced 2026-10-27 12:40:30 +00:00
28 lines
526 B
TypeScript
28 lines
526 B
TypeScript
import { Copy } from "lucide-react";
|
|
import { toast } from "sonner";
|
|
|
|
import { Button } from "@/shared/ui/button";
|
|
|
|
export function CopyButton({
|
|
value,
|
|
label,
|
|
}: {
|
|
value: string;
|
|
label?: string;
|
|
}) {
|
|
return (
|
|
<Button
|
|
onClick={async () => {
|
|
await navigator.clipboard.writeText(value);
|
|
toast.success("Copied to clipboard");
|
|
}}
|
|
size="sm"
|
|
type="button"
|
|
variant="outline"
|
|
>
|
|
<Copy className="h-4 w-4" />
|
|
<span>{label ?? "Copy"}</span>
|
|
</Button>
|
|
);
|
|
}
|