122 components

useCopy@djangocfg/ui-nextjs

Copy to clipboard hook with async support

useCopy Hook
Copy to clipboard hook with async support

Copy Custom Text:

Quick Copy Samples:

Copy this text!
npm install @djangocfg/ui-nextjs
https://github.com/yourusername/repo
const hello = "world";

Usage:

const { copyToClipboard } = useCopy();
const [copied, setCopied] = useState(false);

const handleCopy = async () => {
  await copyToClipboard('text to copy');
  setCopied(true);
  setTimeout(() => setCopied(false), 2000);
};

return (
  <Button onClick={handleCopy}>
    {copied ? 'Copied!' : 'Copy'}
  </Button>
);

Import

Loading code...