Copy Button

A button that copies text to the clipboard with an animated icon swap on success.

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

export function CopyButtonDemo() {

Installation

pnpm dlx shadcn@latest add https://ui.tyap.me/r/styles/base/copy-button.json

Usage

import { CopyButton } from "@/components/ui/copy-button"
<CopyButton value="Text to copy" />

Examples

Size

Use the size prop to change the size of the button.

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

export function CopyButtonSizes() {

Outline

Use variant="outline" for a bordered style.

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

export function CopyButtonOutline() {

API Reference

CopyButton

PropTypeDefault
valuestring
size"sm" | "default" | "lg""default"
variantButtonProps["variant"]"ghost"
timeoutnumber1800
onCopy(value: string) => void
classNamestring