Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Shadcn Clipboard for React and Tailwind

Copy text to the clipboard.

Installation

bunx --bun shadcn@latest add https://kit.dev/r/clipboard.json

Anatomy

Clipboard
├── ClipboardControl
├── ClipboardTrigger
├── ClipboardIndicator
├── ClipboardInput
└── ClipboardLabel

Usage

import { SITE_URL } from "@/lib/brand";
import { Button } from "@/components/ui/button";
import {
  Clipboard,
  ClipboardIndicator,
  ClipboardInput,
  ClipboardTrigger,
} from "@/components/ui/clipboard";
<div className="w-full max-w-sm">
  <Clipboard value={SITE_URL}>
    <ClipboardInput />
    <ClipboardTrigger asChild>
      <Button size="icon-md">
        <ClipboardIndicator />
      </Button>
    </ClipboardTrigger>
  </Clipboard>
</div>

Accessibility

KeyDescription
Enter
Activate the focused control.
Space
Activate the focused control.

Demos

Context

Controlled

Copy Status

Custom Timeout

Different Icon

Icon Only

Root Provider

Value Text

With Label

API Reference

Clipboard

div

PropType
AttributeType

ClipboardControl

div

PropType

ClipboardTrigger

button

PropType
AttributeType

ClipboardIndicator

div

PropType
AttributeType

ClipboardInput

input

PropType
AttributeType

ClipboardLabel

label

PropType
AttributeType

ClipboardValue

span

PropType
AttributeType

ClipboardRootProvider

div

PropType
AttributeType

useClipboard

PropType

ClipboardContext

PropType