Components · Form Controls
Phone Input
A phone field with a country picker. Groups the number as you type and reports it in E.164.
import { PhoneInput } from '@nexub/react';Playground
Props
Type a number, or paste one with its country code
<PhoneInput aria-label="Phone number" defaultCountry="IN" value={value} onValueChange={…} />Examples
Default
Restricted countries in a form field
States
Type a number, or paste one with its country code
defaultType a number, or paste one with its country code
invalidType 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
| Prop | Type | Default | Description |
|---|---|---|---|
| value | string | — | The number in E.164 ("+919847012345"), or an empty string. |
| defaultValue | string | — | 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. |
| defaultCountry | string | — | ISO 3166-1 alpha-2 code to start on. Defaults to the region of the provider locale, else US. |
| country | string | — | Controls the selected country. |
| onCountryChange | ((country: CountryCode) => void) | — | Controls the selected country. |
| countries | string[] | — | 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 / disabled | boolean | — | Field states, with readOnly and required. Inside FormField.Control they come from the field. |
| name | string | — | Submits the E.164 value with a form. |
| sheet | false | 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. |
| invalid | boolean | — |
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.
On iOS & Android: PhoneInput
import { PhoneInput } from '@nexub/react-native';
<PhoneInput label="Mobile number" defaultCountry="SG" value={phone} onValueChange={(e164, { valid }) => setPhone(e164)} />Web vs mobile
Same tokens and prop names. Where the platforms differ:
| Web | iOS & Android | |
|---|---|---|
| Country list | A searchable select, or a sheet on phones with sheet. | Always a bottom sheet with search. |
| Label and errors | Bring your own Label and FormError; invalid turns the outline red. | label is required; error shows the message and the red outline. |
| Keyboard | type="tel". | The phone pad, with the platform’s phone-number autofill. |
Interactive preview of @nexub/react-native rendered for the web. Native chrome (switches, pickers, Liquid Glass) looks like the platform on a device.
On device

iPhone (iOS simulator)

Pixel (Android emulator)
Screenshots from the latest CI run of the showcase app; the live frame renders the same code for the web.
PhoneInput props
| Prop | Type | Default | Description |
|---|---|---|---|
| defaultCountry | CountryCode | — | Country to start on. Defaults to the region of the provider's locale, else US. |
| country | CountryCode | — | Controlled country (ISO 3166-1 alpha-2). |
| onCountryChange | (country: CountryCode) => void | — | — |
| value | string | — | Controlled E.164 value ("+919847012345"), '' when empty. |
| defaultValue | string | — | — |
| onValueChange | (e164: string, details: { country: CountryCode; national: string; valid: boolean }) => void | — | — |
| countries | CountryCode[] | — | Limits the picker to these countries, in this order. One entry shows it as text. |
| invalid | boolean | — | Marks the field invalid for screen readers. For the red outline and a message, give error. |
| size | Extract<ControlSize, 'md' | 'lg' | 'xl'> | 'lg' | Field height on the mobile control ladder (web's sm/md/lg are desktop sizes):
md 40, lg 48, xl 56. The country code text follows it. |
| ref | React.Ref<React.ComponentRef<typeof TextInput>> | — | — |
| labelrequired | string | — | Visible label above the field (also its accessible name). |
| helperText | string | — | Hint under the field. Replaced by error when set. |
| error | string | — | Error message: red outline, announced, replaces the helper text. |
| required | boolean | — | Shows a required marker after the label, like web FormField. Checking the value is up to you. |
| disabled | boolean | — | — |
| readOnly | boolean | — | Shows the value but it can't be changed. The field can still be focused and its text selected and copied; it sits on a quieter surface so it doesn't look editable. |
| leadingIcon | React.ReactNode | — | An icon (or any small node) at the start, inside the field. |
| trailingIcon | React.ReactNode | — | An icon (or any small node) at the end, inside the field, after the clear button. |
| leadingAddon | React.ReactNode | — | Text or a node in its own segment before the field, e.g. "https://". |
| trailingAddon | React.ReactNode | — | Text or a node in its own segment after the field, e.g. ".com" or "kg". |
| trailing | React.ReactNode | — | The older name for trailingIcon: a node at the end, inside the field. |
| clearable | boolean | — | Shows a clear button while there is a value. Clearing fires onChangeText with "". |
| onClear | () => void | — | Called when the clear button empties the field, after onChangeText(""). |
| showCount | boolean | — | Shows a "12/80" counter; needs maxLength. Announced politely near the limit. |
| loading | boolean | — | Spinner in the trailing slot and busy for screen readers. |
| style | StyleProp<ViewStyle> | — | — |