CopyButton
Copy text with honest feedback and a manual fallback.
Interactive preview
--dvy-brand: #087565;Usage
import { CopyButton } from "@devvy-ui/react";
<CopyButton text="--dvy-brand: #087565;">Copy theme token</CopyButton>API reference
Native HTML attributes, className, style and a forwarded ref are supported. Component-specific props:
| Prop | Type | Default | Description |
|---|---|---|---|
| text | string | required | Exact text to copy. |
| onCopyResult | (success: boolean) => void | — | Reports the result. |
| children / loading / disabled | Button props | Copy / false / false | Shared native action behavior. |
Accessibility & behavior
Platform Behavior & Guidelines
Uses the Clipboard API only after activation, prevents overlapping requests and ignores updates after unmount. A rejected/unavailable API exposes a selected, readonly textarea for manual copying; no success is reported on failure. onClick can prevent the copy. Source mode includes Button; preserve permissions and native focus.
Source ownership
Run npx @devvy-ui/cli init once in your React project, then add the source:
npx @devvy-ui/cli add copy-buttonMake the source yours.
Start from the canonical implementation used by the package and registry. Change the code, keep the MIT notice, and build the behavior your project needs.
Edit your own copy. Downloaded source uses your changes; the component preview above uses the shipped version. Run the source installer first to include shared helpers.