Skip to content
nexubDesign System
v11.9.0

Components · Form Controls

Phone Input

AlphaAdded v10.8.0 · updated v11.1.0

A phone field with a country picker. Groups the number as you type and reports it in E.164.

import { PhoneInput } from '@nexub/react';
View as Markdown

Playground

Props

size

Type a number, or paste one with its country code

TSX
<PhoneInput aria-label="Phone number" defaultCountry="IN" value={value} onValueChange={…} />

Examples

Default

Type a number, or paste one with its country code

Restricted countries in a form field

We send a code to confirm it.

States

  • Type a number, or paste one with its country code

    default
  • Type a number, or paste one with its country code

    invalid
  • Type a number, or paste one with its country code

    size="sm"
  • Type a number, or paste one with its country code

    size="md"
  • Type a number, or paste one with its country code

    size="lg"

Props

Props
PropTypeDefaultDescription
valuestring—The number in E.164 ("+919847012345"), or an empty string.
defaultValuestring—The number in E.164 ("+919847012345"), or an empty string.
onValueChange((e164: string, details: { country: CountryCode; national: string; valid: boolean; }) => void)—Called on every change. valid is a length check for the country, not proof the number exists.
defaultCountrystring—ISO 3166-1 alpha-2 code to start on. Defaults to the region of the provider locale, else US.
countrystring—Controls the selected country.
onCountryChange((country: CountryCode) => void)—Controls the selected country.
countriesstring[]—Limits the picker to these countries, in this order. With one entry the picker becomes text.
size'sm' | 'md' | 'lg''md'Height of the field.
invalid / disabledboolean—Field states, with readOnly and required. Inside FormField.Control they come from the field.
namestring—Submits the E.164 value with a form.
sheetfalse | true | 'auto''auto' (pass `sheet={false}` to keep a popover on small screens)Shows the country list as a bottom sheet; 'auto' only on phones.
formatPhone(e164, { style })(e164: string, options?: { style?: 'national' | 'international' }) => string—Read-only display of a stored number: "+91 98470 12345" or "98470 12345".
parsePhone(value)(value: string) => { country, dialCode, national, e164, valid }—The parts, for apps that store the country and number apart. The E.164 string stays the one stored form.
invalidboolean—

Accessibility

Keyboard

  • Tab

    Moves from the country picker to the number.

  • Enter / Space

    Opens the country list; type to filter it.

Notes

  • The picker reads "Country code, India +91". The number field takes its name from the label or `aria-label`.

  • Pasting a full international number picks its country and fills the rest.

  • Validation is plausibility only: confirm the number on the server.