CopyButton

Copies text, then swaps its label for a drawn checkmark. Buttons.

Open playground

About

CopyButton is a React component in the Buttons category of smoui. It is typed, ships no stylesheet, follows your theme through CSS variables, and honors prefers-reduced-motion. Import it with import { CopyButton } from "@ashutoshswamy/smoui" and set text, label, copiedLabel.

Install

Terminal
npm i @ashutoshswamy/smoui

Usage

TSX
import { CopyButton } from "@ashutoshswamy/smoui";

<CopyButton text="npm i @ashutoshswamy/smoui" className="rounded-full bg-neutral-100 px-5 py-2.5" />

Props 3

text

Text written to the clipboard.

string
label

Idle label.

stringdefault "Copy"
copiedLabel

Label after copying.

stringdefault "Copied"