CopyButton

CopyButton is an animated copy button component for React Native and React, from the dissolve library. Icon button that copies text: the copy icon breaks into grains that reform as a check, a Copied tooltip rises.

An icon button that copies text. Press it and the text goes to the clipboard with a success haptic on iOS. The copy icon breaks into a few grains that flow over on a slight arc, shrinking mid flight, and reform as a check with a tiny pop, while a Copied tooltip rises above the button and screen readers announce it. After 1.5 s it settles back to the copy icon; pressing again while the check shows only restarts the countdown. The grains are the one dissolve moment: effects="none" swaps the icons with a plain crossfade. Reduced motion: a crossfade, no pop. React Native copies with expo-clipboard; the web uses the Clipboard API, with the selection fallback on insecure pages.

Install

React Native

Install the engine once per app and wrap the root layout in <DissolveProvider> (see Installation), then copy the component into components/dissolve:

npx expo install dissolve-ui @shopify/react-native-skia react-native-reanimated react-native-worklets react-native-gesture-handler expo-haptics
npx dissolve-ui add copy-button --native
npx shadcn@latest add https://dissolve.rselmi.com/r/native/copy-button.json

React

Needs React 19 and react-dom, nothing else: no engine, no provider, no Tailwind. Works in the Next.js App Router.

npx dissolve-ui add copy-button --web
npx shadcn@latest add https://dissolve.rselmi.com/r/copy-button.json

Usage

CopyButton.tsx (React Native)
import { CopyButton } from '@/components/dissolve/copy-button';

<CopyButton text="npx dissolve-ui add copy-button" />

// The text at press time, smaller, a plain crossfade.
<CopyButton text={() => editor.getValue()} size="sm" effects="none" onCopy={(t) => track('copied', t.length)} />
CopyButton.tsx (React)
import { CopyButton } from '@/components/dissolve/copy-button';

<CopyButton text="npx dissolve-ui add copy-button" />

// The text at press time, smaller, a plain crossfade.
<CopyButton text={() => editor.getValue()} size="sm" effects="none" onCopy={(t) => track('copied', t.length)} />

Props

PropTypeDefaultDescription
textstring | () => stringThe text to copy, or a function that returns it at press time.
onCopy(text: string) => voidCalled with the copied text.
timeoutnumber1500How long the check and the tooltip stay, in ms.
copiedLabelstring'Copied'Tooltip text, also announced to screen readers.
size'sm' | 'md' | 'lg''md'Button and icon size: 32, 36 or 44 pt.
effects'accent' | 'none''accent'Accent: the copy icon breaks into grains that reform as the check. None: a plain crossfade.
hapticsbooleantrueSuccess haptic on copy.
disabledbooleanfalseNo copy, the button shows at 40% opacity.
accessibilityLabelstring'Copy'Read by screen readers.
classNamestringOuter classes (margins, background...). The size comes from the size prop.

Source

Previous: Accordion · Next: AvatarStack · All components

dissolve is MIT licensed. Source on GitHub, package on npm. This page as markdown. For AI agents: llms.txt.