Component libraryCopy button
Components/Essentials

Copy button

Free

Copy text with clear loading, success and retry feedback.

npx shadcn@latest add https://tidalui.com/r/copy-button.json
Desktop viewport

Installation

Terminal
npx shadcn@latest add https://tidalui.com/r/copy-button.json

Import components/ui/tidal.css, components/ui/copy-button.css, then add the component inside a tidal-scope wrapper. Its scoped design tokens keep it independent of your existing CSS.

Usage

Complete example source · Dependency and asset manifest

Loading the complete example…

API & behavior

Exactly one copy source is required: text for a ready string, or getText for a string or Promise resolved at activation time. clipboard injects a writeText adapter and defaults to navigator.clipboard. Partial labels localize idle, pending, success, general error, permission-denied and unavailable states. feedbackDuration is clamped from 600 to 10000ms and defaults to 1800ms. onCopy receives the accepted string; onCopyError receives a normalized kind and the original source or adapter error; onStatusChange reports idle, pending, success and error. Observer callbacks are queued after internal lifecycle commits, so their exceptions surface asynchronously to the host and are never reclassified as copy failures. Native button attributes, type, form ownership, data/ARIA attributes, className and the forwarded button ref are preserved. The native onClick handler runs before the copy request and preventDefault cancels it. Native disabled is respected; explicit aria-disabled true and pending suppress activation while retaining focus. The source owns no navigation, storage or copied content.

Style with the --t-* CSS variables. Set data-theme="dark" on your tidal-scope wrapper for a dark surface. Motion respects the system’s reduced-motion preference.

Building with an agent?Give it the installation guide and component catalog.