uibrik

Copy Button

Preview

Customize

Icon + label
Soft
Medium
Reset after1.5s
Radius12px

Usage

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

<CopyButton />

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.

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.