Copies text and swaps its icon in a quick blur crossfade.
Installation
Install the packages
npm install @prequelui/react motion@prequelui/react reuses the primitive library your components already depend on.
Add the component
npx shadcn@latest add https://animate.prequelui.terravidhal.me/r/copy-button.jsonnpx shadcn@latest add https://animate.prequelui.terravidhal.me/r/copy-button.json
Turn on the motion
npx @prequelui/cli@latest animate copy-buttonThe CLI finds the component through components.json, swaps the import and removes the CSS animation classes that Motion replaces.
Usage
Import the component and compose it exactly like the primitive it wraps. Motion is enabled by default; the tempo prop scales every duration and softens every spring.
import { Check, Copy } from "lucide-react";
import { CopyButton, CopyButtonIcon } from "@/components/prequelui/copy-button";
export default function Demo() {
return (
<CopyButton content="npx shadcn@latest add button">
<CopyButtonIcon icon={<Copy />} copiedIcon={<Check />} />
Copy command
</CopyButton>
);
}import { CopyButton } from "@/components/prequelui/copy-button";
export function Variant() {
return (
<CopyButton tempo={1.2}>
…
</CopyButton>
);
}Animation
Copying swaps one glyph for another in place. The leaving icon shrinks to half, blurs by two pixels and fades in 150 ms while the check takes its place on the same curve; the state returns after three seconds.
- Icon swap: 150 ms, scale 0.5 → 1, blur 2 px → 0.
- The button itself keeps the shared press spring.
- The reset timer is cleared if the button is clicked again.
- Reduced motion keeps the crossfade and removes scale and blur.
API Reference
Each part accepts the usual HTML props in addition to the motion props below. No accessibility prop is hidden behind the animation layer.