Component packs › Ditto › Copy Button

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.

Copy Button props

PropTypeDefaultDescription
valuestringThe text to copy.
labelstring"Promo code"Small label above the field. Default "Promo code".
monobooleantrueMonospace value. Default true.
onCopy(value: string, ok: boolean) => void
darkboolean
autoplaynumber | falseShowcase mode: copies itself every N ms.

Methods on the ref

Use it in React

import CopyButton from './CopyButton';

<CopyButton />

The Vue, HTML, Next.js, Tailwind and Motion versions take the same options.

More in Ditto

Good for: Copy and share.