Skip to content

Copy button

Copy a value with immediate confirmation.

ActionUtility
npx shadcn@latest add @silicon-ui/copy-button

Installation

With the shadcn CLI

npx shadcn@latest add @silicon-ui/copy-button

Manually

  1. Install the dependencies

    npm install lucide-react motion
  2. Copy these files into your project

    • components/silicon-ui/copy-button/copy-button.tsx
    • components/silicon-ui/copy-button/copy-button.module.css

    Shared with other components. Skip any you already have.

    • components/silicon-ui/lib/use-copy-feedback.ts
  3. Add the foundation, once per app, for the design and motion tokens

    npx shadcn@latest add @silicon-ui/silicon-foundation

Usage

usage.tsx
import { CopyButton } from "@/components/silicon-ui/copy-button/copy-button";

API reference

PropTypeDefault
value*string—
labelstring"Copy"
classNamestring—
iconOnlybooleanfalse
variant

`outline` (default) bordered; `plain` quiet, for inside a field; `soft` filled and borderless with a muted label, as Button's soft muted, for a bar (experimental).

"outline" | "plain" | "soft""outline"
size

Height: `sm` 36px (default), or `xs` 24px with 12px words, for a toolbar beside xs controls (experimental).

"xs" | "sm""sm"
shape

The corners (experimental): `soft` (default) has the control radius; `pill` is fully round, a circle when `iconOnly`, as Button's `shape`.

"soft" | "pill""soft"
disabledboolean—
onCopied() => void—

Dependencies

npm
lucide-reactmotion
Registry
silicon-motion-tokens