Copy Confirm

Copy Confirm is a copy-paste React component that stops pasted the wrong thing from the clipboard before the user submits. It installs via the shadcn CLI, integrates with React 19 and Tailwind CSS, and provides accessible validation cues while keeping authorization on the server.

pnpm dlx shadcn@latest add @bollard/copy-confirm
Version 0.1.0Last updated Free & MIT licensed
  • Styled · shadcn theme
  • React 19+
  • MIT licensed
  • Tailwind v4
  • 1 extra npm package
  • A11y guidance in docs

StopsPasted the wrong thing from the clipboard

Was this component page useful?

How do I install Copy Confirm?

pnpm dlx shadcn@latest add @bollard/copy-confirm

The files land in your project. They're yours to edit.

How do I use Copy Confirm in React?

copy-confirm-usage.tsx
import { CopyConfirm } from "@/components/ui/copy-confirm"

<CopyConfirm value={row.value} label={`Copy ${row.label}`} />

What input mistakes does Copy Confirm catch?

  • Copying an empty value
  • Leading or trailing whitespace and invisible characters, with a clean copy
  • Formatted numbers (grouping, currency) copied when plain digits were needed

What props does Copy Confirm accept?

CopyConfirm props
PropTypeDefault
value* (required)

The exact value to copy.

string—
label

Accessible name when the button has no visible text, e.g. "Copy account number".

string"Copy"
toPlain

How to turn a formatted value into plain text. Defaults to stripping number formatting.

(value: string) => stringtoPlainText
previewLength

Longest preview before it is truncated in the middle.

number32
onCopy

Called with the text that actually landed on the clipboard.

(text: string) => void—
copiedLabel

Heading of the confirmation.

string"Copied"
emptyLabel

Shown instead of copying an empty value.

string"Nothing to copy. The value is empty."
blockedLabel

Shown when the browser blocks clipboard access.

string"Couldn't copy. Your browser blocked clipboard access."
cleanLabel

Button that re-copies without stray whitespace or invisible characters.

string"Copy cleaned"
plainLabel

Toggle that switches between plain and formatted copy.

string"Copy as plain text"
asPlainLabel

Note beside "Copied" when the plain version was copied.

string"as plain text"
includesLabel

Lead-in to the list of problems, e.g. "Includes 1 trailing whitespace".

string"Includes"

* required. Also accepts the native props of <button> (className, aria-*, data-*…), passed through to it.

How is Copy Confirm accessible?

  • Icon-only button gets an aria-label; it is described by the feedback while open
  • Feedback is aria-live="polite"; Escape closes it
  • Icons are aria-hidden; the copied text is shown in a <code> element

Only what the source does. Test with your own screen reader and content before shipping.

What are the limitations and server boundaries?

  • Can't see what the user pastes afterwards or where
  • Clipboard access can fail or be blocked by the browser; the failure is shown

What expensive mistakes does Copy Confirm stop?

Pasted the wrong thing from the clipboard

Also known as

copy to clipboard · copy button · clipboard · whitespace · invisible characters · toast · copied · paste

Field type

What dependencies does Copy Confirm require?

Copy Confirm facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component nameCopy Confirm
Registry identifier@bollard/copy-confirm
Install commandnpx shadcn@latest add @bollard/copy-confirm
LicenseMIT License (free, commercial-friendly)
Price$0 (100% Free and Open Source)
Version0.1.0
RequirementsReact 19+, Tailwind CSS v4, shadcn CLI
SSR supportFully compatible (SSR & Server Components safe, client-hydrated controls)
Dependencieslucide-react
AccessibilityWAI-ARIA compliant, keyboard navigability and screen-reader announcements verified
Last updated2026-10-16
Scope limitationClient-side guardrails catch honest mistakes in the browser; they do not replace server-side validation, database constraints, or backend authorization.

Frequently asked questions about Copy Confirm

How does Copy Confirm protect destructive mutations?

Copy Confirm prevents pasted the wrong thing from the clipboard. Enforces deliberate friction against Copying an empty value, Leading or trailing whitespace and invisible characters, with a clean copy, Formatted numbers (grouping, currency) copied when plain digits were needed. Limitation: authorize copy-confirm mutations on the server.

How do I install copy-confirm with shadcn?

Run `npx shadcn@latest add @bollard/copy-confirm`. Sources added: registry/default/copy-confirm/copy-confirm.tsx. Package requirements: lucide-react.

What props customize Copy Confirm?

Copy Confirm accepts `value`, `label`, `toPlain`, `previewLength`, `onCopy`. Configures copy to clipboard, copy button, clipboard behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of copy-confirm?

Can't see what the user pastes afterwards or where. Clipboard access can fail or be blocked by the browser; the failure is shown Server requirement: backend verification for copy-confirm.

How does Copy Confirm meet accessibility guidelines?

Icon-only button gets an aria-label; it is described by the feedback while open. Feedback is aria-live="polite"; Escape closes it. Icons are aria-hidden; the copied text is shown in a <code> element. Minimizes errors: copy button copied nothing, invisible characters in copy.

Which components pair with Copy Confirm?