PIN Code Input

PIN Code Input is a copy-paste React component that stops parcel sent to the wrong state 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/pincode-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

StopsParcel sent to the wrong state

Was this component page useful?

How do I install PIN Code Input?

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

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

How do I use PIN Code Input in React?

pincode-input-usage.tsx
import { PincodeInput } from "@/components/ui/pincode-input"

<PincodeInput value={pin} onValueChange={setPin} lookup={lookupDemoPin} state={state} onUseState={setState} city={city} onUseCity={setCity} />

What input mistakes does PIN Code Input catch?

  • PIN prefix that doesn't match the chosen state
  • Letter O for 0, and digits from other scripts
  • Wrong length or unused prefixes
  • Army Post Office codes
  • US ZIP or UK postcodes typed for India, with a country switch

What props does PIN Code Input accept?

PincodeInput props
PropTypeDefault
label

Visible label.

string"PIN code"
value

Controlled code (other-script digits converted, spaces removed for India).

string—
defaultValue

Initial code when uncontrolled.

string""
onValueChange

Called with the cleaned code on every change.

(value: string) => void—
country

ISO country the address is in. India gets full PIN checks; others get a shape check.

string"IN"
onCountryChange

Offered as a one-tap switch when the code looks like it belongs to another country.

(country: string) => void—
state

The state picked elsewhere in the form, checked against the PIN.

string—
onUseState

Lets the user take the PIN's state in one tap.

(state: string) => void—
city

The city typed elsewhere in the form, checked against the lookup.

string—
onUseCity

Lets the user take the PIN's district in one tap.

(city: string) => void—
lookup

Finds where a complete Indian PIN is. Resolve null when no place is returned, undefined when the lookup cannot check it. See createIndiaPostLookup.

(pin: string, signal: AbortSignal) => Promise<PinPlace | null | undefined>—
onPlaceChange

Called with the place once found, or null when the PIN changes or isn't found/checked.

(place: PinPlace | null) => void—
messages

Override any message or label.

Partial<typeof PINCODE_MESSAGES>—

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

How is PIN Code Input accessible?

  • Visible label; input has aria-invalid when the lookup finds nothing and is described by a polite status
  • Fixes are buttons; focus returns to the input
  • Icons are aria-hidden

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

What are the limitations and server boundaries?

  • Prefix-to-state is a table and can't tell every border case without the lookup
  • Format looks valid is not the same as deliverable
  • Area and city checks need your lookup

What validation rules apply to PIN Code Input?

Rules not yet verified against an official source.

Not verified this round: the prefix-to-state table is from India Post via Wikipedia ("Postal Index Number"), not a primary India Post source. Copied components don't update themselves, so re-check after rule changes (see updating a component).

What expensive mistakes does PIN Code Input stop?

Parcel sent to the wrong state

Also known as

pincode · pin code · postal code · zip · india post · shipping address · checkout · delivery

Field type

What dependencies does PIN Code Input require?

PIN Code Input facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component namePIN Code Input
Registry identifier@bollard/pincode-input
Install commandnpx shadcn@latest add @bollard/pincode-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-19
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 PIN Code Input

How does PIN Code Input validate Indian financial identifiers?

PIN Code Input stops parcel sent to the wrong state. Complies with national standards for PIN prefix that doesn't match the chosen state, Letter O for 0, and digits from other scripts, Wrong length or unused prefixes, Army Post Office codes, US ZIP or UK postcodes typed for India, with a country switch. Limitation: verify pincode-input with issuer gateway.

How do I install pincode-input with shadcn?

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

What props customize PIN Code Input?

PIN Code Input accepts `label`, `value`, `defaultValue`, `onValueChange`, `country`. Configures pincode, pin code, postal code behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of pincode-input?

Prefix-to-state is a table and can't tell every border case without the lookup. Format looks valid is not the same as deliverable. Area and city checks need your lookup Server requirement: backend verification for pincode-input.

How does PIN Code Input meet accessibility guidelines?

Visible label; input has aria-invalid when the lookup finds nothing and is described by a polite status. Fixes are buttons; focus returns to the input. Icons are aria-hidden. Minimizes errors: pincode state mismatch, invalid pin code.

Which components pair with PIN Code Input?