spb/autoscholar
Public
1"use client";2import { useState } from "react";34export function CopyButton({ text, label = "Copy" }: { text: string; label?: string }) {5 const [done, setDone] = useState(false);6 return (7 <button8 type="button"9 className="btn btn-sm"10 onClick={async () => {11 try {12 await navigator.clipboard.writeText(text);13 setDone(true);14 setTimeout(() => setDone(false), 1500);15 } catch {16 /* clipboard unavailable */17 }18 }}19 aria-live="polite"20 >21 {done ? "Copied" : label}22 </button>23 );24}25