Openstatus
www.openstatus.dev
1"use client";
2
3import { useCopyToClipboard } from "@/hooks/use-copy-to-clipboard";
4import { cn } from "@/lib/utils";
5import { Button } from "@openstatus/ui";
6
7export function CopyButton({
8 className,
9 copyText,
10 buttonText = "copy",
11 copiedText = "copied",
12 ...props
13}: React.ComponentProps<typeof Button> & {
14 copyText: string;
15 buttonText?: string;
16 copiedText?: string;
17}) {
18 const { copy, isCopied } = useCopyToClipboard();
19
20 return (
21 <Button
22 variant="ghost"
23 size="lg"
24 className={cn("rounded-none p-4", className)}
25 onClick={() => copy(copyText, { withToast: true })}
26 {...props}
27 >
28 {isCopied ? `[${copiedText}]` : `[${buttonText}]`}
29 </Button>
30 );
31}