Component packs › Ditto › Copy Button
Press Copy and a slip with the code lifts off the field, arcs over and drops into the clipboard, whose paper fills with lines and a check.
Copy Button is a copy from Ditto, a component pack with 6 copy and share controls: Copy and share where you see the copy happen: the text lifts off and drops into the clipboard. Price: $2 for the whole pack.
Built with: ghost flight on an arc, filling clipboard icon, clipboard with fallback.
Code: React and Next.js (TypeScript), Vue 3, plain HTML/CSS/JS, Tailwind CSS v4 and Motion (motion.dev). No npm packages needed. Keyboard accessible, with a reduced-motion version, in dark and light.
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | The text to copy. | |
label | string | "Promo code" | Small label above the field. Default "Promo code". |
mono | boolean | true | Monospace value. Default true. |
onCopy | (value: string, ok: boolean) => void | ||
dark | boolean | ||
autoplay | number | false | Showcase mode: copies itself every N ms. |
copy(): Promise<boolean>setValue(v: string): voiddestroy(): voidimport CopyButton from './CopyButton';
<CopyButton />The Vue, HTML, Next.js, Tailwind and Motion versions take the same options.
Good for: Copy and share.