Name Input

Spots caps lock, all-lowercase, stray digits and swapped first/last names, and offers (never forces) a correctly cased fix.

StopsNames saved in caps or swapped

Installation

pnpm dlx shadcn@latest add https://bollard-ui.vercel.app/r/name-input.json

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

Usage

name-input-usage.tsx
import { NameFields, NameInput } from "@/components/ui/name-input"

<NameInput label="Account holder" defaultValue="PRIYA sharma" />

What it catches

  • ALL CAPS or all-lowercase names
  • Digits and doubled spaces
  • First and last names swapped (from common-name lists)
  • A full name typed into one box: offers to split
  • Re-casing that respects Mc/Mac, O', particles and hyphens

Props

NameInput props
PropTypeDefault
label

Visible label.

string"Full name"
value

Controlled value.

string—
defaultValue

Initial value when uncontrolled.

string""
onValueChange

Called with the value exactly as typed. Nothing is ever rewritten without a tap.

(value: string) => void—
hint

Helper text shown while there is nothing to point out.

string—
surname

The field holds only a family name, so a leading particle stays lower case ("van der Berg").

booleanfalse
delay

Pause in ms before suggestions appear while typing. Leaving the field shows them at once.

number700
capsMessage

Shown when the name is in capitals.

string"Typed in capitals?"
lowerMessage

Shown when the name is all lowercase.

string"Names usually start with a capital."
digitsMessage

Shown when a name has digits; receives them, e.g. "2".

(digits: string) => string(digits) => `Names rarely contain digits (${digits}).`
spacesMessage

Shown for doubled or stray spaces.

string"There's an extra space."
fixLabel

Fix button text; receives the suggested name.

(fix: string) => string(fix) => `Use “${fix}”`
keepLabel

Accessible label of the button that keeps the name as typed.

string"Keep it as typed"

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

Accessibility

  • Visible label; input is described by a polite hint region
  • Warnings appear after a pause while typing
  • Keep button has an aria-label and title; icons are aria-hidden

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

Limitations

  • Casing and swap lists are English/Western-centric; they can be wrong for other naming traditions
  • Only suggests; some people really write their name in capitals or lowercase
  • Mac names are a list, so unlisted ones aren't re-cased

What it stops

Names saved in caps or swapped

Also known as

name · full name · first name · last name · signup · profile · title case · customer name

Field type

Dependencies

Pairs well with