Stop Rebuilding UI

Shadcn.io is not affiliated with official shadcn/ui

React useCopyToClipboard Hook

React useCopyToClipboard hook with async copy function and copied state. Uses Clipboard API, auto-resets after 2s.

Copy text to clipboard with one function call. Returns [copy, isCopied]—call copy(text) and show feedback with isCopied. State auto-resets after 2 seconds. Uses the modern Clipboard API with fallback warning. Handles errors gracefully without throwing. Perfect for copy buttons, code snippets, share links, or any "click to copy" UI pattern.

React useCopyToClipboard Hook preview

Scroll to load preview

Installation

FAQ

Was this page helpful?

Sign in to leave feedback.