Clean Paste Input

Clean Paste Input is a copy-paste React component that stops pasted code fails from hidden characters 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/clean-paste-input
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 code fails from hidden characters

Was this component page useful?

How do I install Clean Paste Input?

pnpm dlx shadcn@latest add @bollard/clean-paste-input

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

How do I use Clean Paste Input in React?

clean-paste-input-usage.tsx
import { CleanPasteInput } from "@/components/ui/clean-paste-input"

<CleanPasteInput label="Coupon code" defaultValue={SAVED_DRAFT} autoComplete="off" spellCheck={false} />

What input mistakes does Clean Paste Input catch?

  • Zero-width spaces and joiners, and byte-order marks
  • Soft hyphens
  • Bidirectional control characters
  • Hidden characters arriving by other routes than paste, with a fix

What props does Clean Paste Input accept?

CleanPasteInput props
PropTypeDefault
label

Visible label.

string"Text"
hint

Helper text shown while there is nothing to report.

string—
multiline

Render a textarea instead of a single-line input.

booleanfalse
value

Controlled value.

string—
defaultValue

Initial value when uncontrolled.

string""
onValueChange

Called with the new value on every change.

(value: string) => void—
messages

Reword or translate any message.

Partial<typeof CLEAN_PASTE_MESSAGES>—
ref

Ref to the underlying input or textarea.

React.Ref<HTMLInputElement | HTMLTextAreaElement>—

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

How is Clean Paste Input accessible?

  • Visible <label>; the field is described by an aria-live="polite" notice
  • Undo and dismiss are buttons; dismiss has an aria-label
  • Actions return focus to the field

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

What are the limitations and server boundaries?

  • Doesn't change visible look-alike characters (Cyrillic а for Latin a)
  • Removing joiners can change text in scripts or emoji that need them; use undo where that matters

What expensive mistakes does Clean Paste Input stop?

Pasted code fails from hidden characters

Also known as

zero-width · invisible characters · paste · sanitize · bom · voucher code · api key · clean input

Field type

What dependencies does Clean Paste Input require?

Clean Paste Input facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component nameClean Paste Input
Registry identifier@bollard/clean-paste-input
Install commandnpx shadcn@latest add @bollard/clean-paste-input
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 Clean Paste Input

What form validation mistake does Clean Paste Input catch?

Clean Paste Input prevents pasted code fails from hidden characters. Strips invisible characters from pasted codes and IDs, so values that look identical don't fail for hidden reasons. Catches: Zero-width spaces and joiners, and byte-order marks, Soft hyphens, Bidirectional control characters, Hidden characters arriving by other routes than paste, with a fix. Limitation: validate clean-paste-input schemas on backend.

How do I install clean-paste-input with shadcn?

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

What props customize Clean Paste Input?

Clean Paste Input accepts `label`, `hint`, `multiline`, `value`, `defaultValue`. Configures zero-width, invisible characters, paste behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of clean-paste-input?

Doesn't change visible look-alike characters (Cyrillic а for Latin a). Removing joiners can change text in scripts or emoji that need them; use undo where that matters Server requirement: backend verification for clean-paste-input.

How does Clean Paste Input meet accessibility guidelines?

Visible <label>; the field is described by an aria-live="polite" notice. Undo and dismiss are buttons; dismiss has an aria-label. Actions return focus to the field. Minimizes errors: zero width space in paste, copied code not matching.

Which components pair with Clean Paste Input?