Skip to content

shadcn.io is not affiliated with official shadcn/ui

Shadcn Clipboard for React Radix UI

Copy text to the clipboard.

Framework
UI library

Radix UI does not include this primitive, so this page uses the Ark UI component. The visuals match the Ark UI version.

Installation

bunx --bun shadcn@latest add https://kit.dev/r/radix/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
AttributeType

ClipboardTrigger

button

PropType
AttributeType

ClipboardIndicator

div

PropType
AttributeType

ClipboardInput

input

PropType
AttributeType

ClipboardLabel

label

PropType
AttributeType

ClipboardValue

span

PropType
AttributeType

ClipboardRootProvider

div

PropType
valueUseClipboardReturn
AttributeType

useClipboard

PropType

ClipboardContext

PropType