Phone Input

Phone Input is a copy-paste React component that stops unreachable phone number saved 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/phone-input
Version 0.1.0Last updated Free & MIT licensed
  • Styled · shadcn theme
  • React 19+
  • MIT licensed
  • Tailwind v4
  • 3 extra npm packages
  • A11y guidance in docs

StopsUnreachable phone number saved

Was this component page useful?

How do I install Phone Input?

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

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

How do I use Phone Input in React?

phone-input-usage.tsx
import { PhoneInput } from "@/components/ui/phone-input"

<PhoneInput
  label="Your mobile"
  defaultValue="+91 +91 098765-43210"
  preferredCountries={["IN", "US", "GB", "AE", "SG"]}
  onNumberChange={(e164) => setSaved(e164)}
/>

What input mistakes does Phone Input catch?

  • Separators, a leading trunk 0 and doubled country codes in pasted numbers
  • Country picked from the dial code and NANP area code
  • Too few or too many digits for the country
  • Line type that doesn't fit (landline or premium-rate where a mobile is expected)
  • E.164 readback of exactly what will be saved

What props does Phone Input accept?

PhoneInput props
PropTypeDefault
label

Visible label.

string"Phone number"
hint

Helper text shown under the field while it is empty.

string—
value

Controlled text in the number field.

string—
defaultValue

Initial text when uncontrolled; it is tidied on mount like a paste.

string""
onValueChange

Called with the field's text on every change.

(value: string) => void—
onNumberChange

Called with the E.164 number (+919876543210), or `null` while it isn't a valid length, plus its line type and range check.

(e164: string | null, country: C, details: PhoneDetails) => void—
expect

`mobile` warns when the number is a landline, toll-free or premium line (an SMS/OTP field). Default `any`.

"mobile" | "any""any"
country

Controlled country. A typed or pasted +code still reports its country through `onCountryChange`.

C—
defaultCountry

Country selected before anything is typed (uncontrolled). Falls back to the first country offered.

C"IN" as C
onCountryChange

Called when the country changes, from the picker or a detected dial code.

(country: C) => void—
countries

Countries to offer: built-in codes (`["IN", "US"]`) or your own table. Defaults to all 245 built in.

PhoneCountryList<C>—
preferredCountries

Codes pinned to the top of the picker, in this order.

readonly C[]—
locale

BCP 47 locale for country names and their order (e.g. "de"). Defaults to the English names in the data.

string—
countryLabel

Accessible label of the country picker.

string"Country"
savesAsLabel

Text before the read-back of the stored number.

string"Saves as"
messages

Override the clean-up notes and warnings (see `PHONE_MESSAGES`).

Partial<PhoneMessages>—

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

How is Phone Input accessible?

  • Visible label; country picker has an aria-label
  • Input has aria-invalid on a warning and is described by a polite hint region
  • Flag and dial code visuals are aria-hidden
  • Animations are skipped under reduced motion

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

What are the limitations and server boundaries?

  • Format looks valid is not the same as reachable or owned; verify with an OTP
  • Numbering data comes from libphonenumber and needs updates as plans change
  • Country names are English unless you pass locale

What expensive mistakes does Phone Input stop?

Unreachable phone number saved

Also known as

+91 · mobile number · otp · indian phone · phone number · country code · libphonenumber · e.164

Field type

What dependencies does Phone Input require?

Phone Input facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component namePhone Input
Registry identifier@bollard/phone-input
Install commandnpx shadcn@latest add @bollard/phone-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, libphonenumber-js, motion
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 Phone Input

How does Phone Input validate Indian financial identifiers?

Phone Input stops unreachable phone number saved. Complies with national standards for Separators, a leading trunk 0 and doubled country codes in pasted numbers, Country picked from the dial code and NANP area code, Too few or too many digits for the country, Line type that doesn't fit (landline or premium-rate where a mobile is expected), E.164 readback of exactly what will be saved. Limitation: verify phone-input with issuer gateway.

How do I install phone-input with shadcn?

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

What props customize Phone Input?

Phone Input accepts `label`, `hint`, `value`, `defaultValue`, `onValueChange`. Configures +91, mobile number, otp behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of phone-input?

Format looks valid is not the same as reachable or owned; verify with an OTP. Numbering data comes from libphonenumber and needs updates as plans change. Country names are English unless you pass locale Server requirement: backend verification for phone-input.

How does Phone Input meet accessibility guidelines?

Visible label; country picker has an aria-label. Input has aria-invalid on a warning and is described by a polite hint region. Flag and dial code visuals are aria-hidden. Animations are skipped under reduced motion. Minimizes errors: indian phone validation, double +91 in number.

Which components pair with Phone Input?