Black Friday: 30% off Pro

Get 30% off

Updated

Copy Button

Preview

Customize

Icon + label
Soft
Medium
Reset after1.5s
Radius12px

Installation

npx shadcn@latest add https://uibrik.com/r/copy-button.json
Adds the files to components/uibrik/copy-button and installs motion and react-use-measure. With the @uibrik namespace set up: npx shadcn@latest add @uibrik/copy-button.

Usage

import { CopyButton } from "@/components/uibrik/copy-button/copy-button";​<CopyButton  text="npm install motion"  label="Copy"  copiedLabel="Copied"  display="label"  variant="soft"  size="md"  tintSuccess={false}  resetAfter={1.5}  radius={12}  onCopy={(text) => {}}/>

Where to use Copy Button

  • Code snippets

    Sheets sliding into a check confirm the copy without a toast covering the code.

    Pairs with Code Block

  • API keys and invite links

    A label that rolls to Copied gives a clear success state for one-off secrets and links.

    Pairs with Settings Page

  • Coupon and referral codes

    A clear confirmation helps shoppers trust the code is on their clipboard before checkout.

Props

CopyButton
text
Type string
"npm install motion"
Text written to the clipboard.
label
Type string
"Copy"
Button text.
copiedLabel
Type string
"Copied"
Shown once the text is copied.
display
Type "label" | "icon"
"label"
Icon and label, or the icon alone (the label stays as its accessible name).
variant
Type "soft" | "ghost" | "outline"
"soft"
Filled, transparent until hovered, or outlined.
size
Type "sm" | "md" | "lg"
"md"
Height, padding and text size.
tintSuccess
Type boolean
false
Colour the copied state instead of keeping it neutral.
successColor
Type string
"#16a34a"
Colour of the copied state when tinted.
resetAfter
Type number
1.5
How long Copied shows before reverting.
radius
Type number
12
Corner radius.
onCopy
Type (text: string) => void
–
Called after a successful copy.
className
Type string
–
Classes for the button.