Component packs › Ditto › Code Copy

Code Copy

Each line of the code block peels off in turn and streams into the clipboard, top to bottom, before the button says copied.

Code Copy 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: staggered line flights, token colouring, line numbers left out of the copy.

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.

Code Copy props

PropTypeDefaultDescription
codestringThe code.
filestring"install.sh"File or language shown in the header. Default "install.sh".
onCopy(code: string, ok: boolean) => void
darkboolean
autoplaynumber | falseShowcase mode: copies itself every N ms.

Methods on the ref

Use it in React

import CodeCopy from './CodeCopy';

<CodeCopy />

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

More in Ditto

Good for: Copy and share.