Copy Button

React copy to clipboard button that writes a value, then swaps to a check icon and Copied label for a moment. Accepts every Button variant and size.

src/registry/ui/copy-button.tsx/r/copy-button.json

Installation#

bash
npx shadcn@latest add @minidev/copy-button

MiniDev UI is in the shadcn registry directory, so the short form works with no setup. Older CLI versions can use the full URL: npx shadcn@latest add https://ui.minidev.pro/r/copy-button.json

Usage#

tsx
import { CopyButton } from "@/components/ui/copy-button"

export function Example() {
  return (
    <CopyButton value="minidev-ui-kit" />
  )
}

API reference#

CopyButton props
PropTypeDefault
value*string-
labelstring"Copy"
copiedLabelstring"Copied"

Also accepts every prop of <button>, passed through to the root element.

* required

Dependencies#

npm

class-variance-authoritylucide-react

Built from

Examples#

All button components

Learn more