Files
homelab-optimized/dashboard/ui/components/copyable.tsx
Gitea Mirror Bot febaf56ba4
Some checks failed
Documentation / Build Docusaurus (push) Has started running
Documentation / Deploy to GitHub Pages (push) Has been cancelled
Sanitized mirror from private repository - 2026-04-16 07:12:52 UTC
2026-04-16 07:12:52 +00:00

23 lines
591 B
TypeScript

"use client";
import { useState, useCallback } from "react";
export function Copyable({ text, className = "" }: { text: string; className?: string }) {
const [copied, setCopied] = useState(false);
const copy = useCallback(() => {
navigator.clipboard.writeText(text);
setCopied(true);
setTimeout(() => setCopied(false), 1500);
}, [text]);
return (
<span
onClick={copy}
className={`cursor-pointer hover:underline decoration-dotted underline-offset-2 ${className}`}
title="Click to copy"
>
{copied ? "OK copied" : text}
</span>
);
}