TypeScript 97.5%
SQL 1.4%
Python 0.8%
1"use client";2import * as React from "react";3import { Check, Copy } from "lucide-react";4import { Button, type ButtonProps } from "./button";5import { cn } from "@/lib/utils";67export function CopyButton({ value, className, label, size = "icon-sm", variant = "ghost", ...props }: { value: string; label?: string } & Omit<ButtonProps, "onClick" | "children">) {8 const [copied, setCopied] = React.useState(false);9 return (10 <Button11 type="button"12 size={label ? (size === "icon-sm" ? "sm" : size) : size}13 variant={variant}14 className={cn("text-fg-muted", className)}15 onClick={async () => {16 try {17 await navigator.clipboard.writeText(value);18 setCopied(true);19 setTimeout(() => setCopied(false), 1500);20 } catch {}21 }}22 aria-label={copied ? "Copied" : "Copy to clipboard"}23 {...props}24 >25 {copied ? <Check className="text-success" /> : <Copy />}26 {label ? <span>{copied ? "Copied" : label}</span> : null}27 </Button>28 );29}30