Username Input

Username Input is a copy-paste React component that stops handle impersonates someone else 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/username-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

StopsHandle impersonates someone else

Was this component page useful?

How do I install Username Input?

pnpm dlx shadcn@latest add @bollard/username-input

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

How do I use Username Input in React?

username-input-usage.tsx
import { UsernameInput } from "@/components/ui/username-input"

<UsernameInput label="Username" defaultValue="Pr1ya_Sharma" existing={verified} checkAvailability={checkAvailability} />

What input mistakes does Username Input catch?

  • Reserved and staff words, including digit swaps (adm1n)
  • Case-only duplicates of existing handles
  • Lookalikes of existing names (Cyrillic/Greek homoglyphs, 0/o, 1/l)
  • Length outside minLength–maxLength
  • Taken handles, with free alternatives

What props does Username Input accept?

UsernameInput props
PropTypeDefault
label

Visible label.

string"Username"
value

Controlled value, as typed (without the

string—
defaultValue

Initial value when uncontrolled.

string""
onValueChange

Called with the cleaned text and the canonical handle, or null while the handle can't be used.

(value: string, handle: string | null) => void—
reserved

Words nobody may register, also caught in disguise (adm1n, supp0rt).

string[]RESERVED_USERNAMES
existing

Handles that exist, e.g. verified or staff accounts, checked for case-only and look-alike clashes.

string[][]
checkAvailability

Resolves whether the canonical handle is free. Debounced; stale answers are ignored. Keep it stable.

(handle: string, signal: AbortSignal) => AvailabilityResult | Promise<AvailabilityResult>—
minLength

Fewest characters.

number3
maxLength

Most characters.

number30
delay

Pause in ms before checking availability.

number400
messages

Override any of the default messages.

Partial<typeof USERNAME_MESSAGES>—

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

How is Username Input accessible?

  • Visible <label>; aria-invalid on blocking issues and status via aria-describedby
  • Status in a polite live region; blocking errors use role=alert
  • Suggestions are buttons

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

What are the limitations and server boundaries?

This is a UX guard rail. Enforce on the server: Enforce uniqueness on the normalised, skeleton form of the handle with a database constraint.

  • Skeleton folding covers common confusables, not the full UTS #39 data
  • Availability depends on your checkAvailability; race conditions remain until the server reserves the name

What expensive mistakes does Username Input stop?

Handle impersonates someone else

Also known as

username · handle · @handle · signup · profile url · availability check · reserved names · display name

Field type

What dependencies does Username Input require?

Username Input facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component nameUsername Input
Registry identifier@bollard/username-input
Install commandnpx shadcn@latest add @bollard/username-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 Username Input

What form validation mistake does Username Input catch?

Username Input prevents handle impersonates someone else. Reads back the exact handle that will be registered and blocks reserved words, case-only duplicates and lookalikes of existing names. Catches: Reserved and staff words, including digit swaps (adm1n), Case-only duplicates of existing handles, Lookalikes of existing names (Cyrillic/Greek homoglyphs, 0/o, 1/l), Length outside minLength–maxLength, Taken handles, with free alternatives. Limitation: validate username-input schemas on backend.

How do I install username-input with shadcn?

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

What props customize Username Input?

Username Input accepts `label`, `value`, `defaultValue`, `onValueChange`, `reserved`. Configures username, handle, @handle behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of username-input?

Skeleton folding covers common confusables, not the full UTS #39 data. Availability depends on your checkAvailability; race conditions remain until the server reserves the name Server requirement: Enforce uniqueness on the normalised, skeleton form of the handle with a database constraint.

How does Username Input meet accessibility guidelines?

Visible <label>; aria-invalid on blocking issues and status via aria-describedby. Status in a polite live region; blocking errors use role=alert. Suggestions are buttons. Minimizes errors: username already taken, reserved username admin.

Which components pair with Username Input?