Copy
An animated copy icon built from SVG rect and path elements that slide apart on hover, mimicking a copy-to-clipboard gesture. It is driven by Motion spring transitions and can also be controlled imperatively through a ref.


Installed with plain
See how it was built shadcn add · no workarounds · theme neutral (none shipped)Installation
pnpm dlx shadcn@latest add https://lucide-animated.com/r/copy.json
Usage
usage.tsx
import { CopyIcon } from "@/components/ui/copy";export default function Example() { return <CopyIcon size={24} className="text-zinc-700" />;}- Copy-to-clipboard buttons where a playful confirmation-style hover animation is desired
- Toolbar or table action icons that need a subtle, lively micro-interaction
- Code blocks or share panels that want an animated copy affordance
- Cases where the animation must be triggered programmatically (e.g. after a successful copy) via a ref
Examples
Copy button with hover animation
Icon inside a button; hovering the wrapper triggers the built-in animation.
copy-button-with-hover-animation.tsx
import { CopyIcon } from "@/components/ui/copy";export default function CopyButton() { return ( <button type="button" aria-label="Copy to clipboard" className="inline-flex items-center justify-center rounded-md p-2 hover:bg-zinc-100" > <CopyIcon size={20} /> </button> );}Programmatic control via ref
Start the animation on click and stop it after a delay, using the imperative handle.
programmatic-control-via-ref.tsx
"use client";import { useRef } from "react";import type { CopyIconHandle } from "@/components/ui/copy";import { CopyIcon } from "@/components/ui/copy";export default function ControlledCopy() { const iconRef = useRef<CopyIconHandle>(null); const handleClick = () => { iconRef.current?.startAnimation(); setTimeout(() => iconRef.current?.stopAnimation(), 1000); }; return ( <button type="button" aria-label="Copy" onClick={handleClick}> <CopyIcon ref={iconRef} size={24} /> </button> );}Custom size and color in a menu item
Uses size and className to match surrounding typography.
custom-size-and-color-in-a-menu-item.tsx
import { CopyIcon } from "@/components/ui/copy";export default function MenuItem() { return ( <div role="menuitem" className="flex items-center gap-2 text-sm text-blue-600"> <CopyIcon size={16} /> <span>Copy link</span> </div> );}API reference
PropTypeDefaultDescription
sizenumber28Width and height of the rendered SVG in pixels.
classNamestring—Class names applied to the outer wrapper div (merged with cn).
onMouseEnter(e: React.MouseEvent<HTMLDivElement>) => void—Called on mouse enter. When the ref handle is attached, the default hover animation is disabled and this handler is invoked instead.
onMouseLeave(e: React.MouseEvent<HTMLDivElement>) => void—Called on mouse leave. When the ref handle is attached, the default hover animation is disabled and this handler is invoked instead.
refReact.Ref<CopyIconHandle>—Exposes startAnimation() and stopAnimation() to control the animation imperatively.
...HTMLAttributes<HTMLDivElement>HTMLAttributes<HTMLDivElement>—All other standard div attributes are spread onto the outer wrapper element.
Accessibility
- The component renders decorative SVG with no title or role; provide an accessible name on the parent button (aria-label or visible text).
- The wrapper is a plain div, so when used as an interactive control place it inside a button or link rather than making the div itself focusable.
- Hover animation is purely visual; do not rely on it to convey state. Pair with a text or aria-live announcement when copy succeeds.
- Respect reduced-motion preferences by disabling or shortening the animation in user-level CSS or by controlling it via the ref when motion should be suppressed.
- Icon color follows currentColor, so maintain sufficient contrast against the background.
Docs written by anthropic:claude-haiku-5-5 from the registry source.
Use with Coding Agent
Paste this into Claude Code, Codex or Cursor. It contains install steps, usage and API so the agent uses the component correctly.
prompt.md
Use the "Copy" component (lucide-animated/copy) from its shadcn registry.1. Install it with: npx shadcn@latest add https://lucide-animated.com/r/copy.json2. Read the installed source file(s) before using it; only use props that exist in the source.3. Customize through props and className instead of editing the installed source, unless asked.4. Available props: size, className, onMouseEnter, onMouseLeave, ref, ...HTMLAttributes<HTMLDivElement>.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { CopyIcon } from "@/components/ui/copy";export default function Example() { return <CopyIcon size={24} className="text-zinc-700" />;}```Files & dependencies
- copy.tsx
dependenciesmotion