Rxova
Skip to content

PhoneInputProps

optional aria-describedby?: string;

ids of external error/help text.


optional aria-label?: string;

Accessible name, when there is no visible text to point label at. Wins over label if both are given.


optional autoFocus?: boolean;

Focus the field on mount.

false

optional className?: string;

optional countries?: string[];

Restrict the list, in the order given. An empty array is ignored — a picker with nothing in it is not a usable field.


optional country?: string;

Controlled selected country, ISO 3166-1 alpha-2.


optional countryLabel?: string;

Accessible name for the country select.

'Country'

optional defaultCountry?: string;

Initial country for the uncontrolled case.

'US'

optional defaultValue?: string;

Uncontrolled initial value in E.164. Ignored when value is provided.


optional dir?: "ltr" | "rtl";

Writing direction for the field. Inherited from the document when unset.


optional disabled?: boolean;

optional hideCountrySelect?: boolean;

Drop the country select and require numbers to be typed in +… form.


optional id?: string;

Base id; the input, select and hidden field derive ids from it.


optional invalid?: boolean;

Sets aria-invalid and data-invalid.


optional label?: ReactNode;

Accessible name for the field. Not rendered — supply your own visible <label htmlFor={${id}-input}> when the design calls for one, exactly as every other input in the suite expects. A node is exposed through a hidden element, since aria-label only takes a string.


optional locale?: string;

BCP 47 tag for country names.

the runtime's locale

optional maxLength?: number;

Longest text the field accepts, in characters.

The cap is always applied; this prop only moves it. An unbounded phone field is a denial-of-service surface — every keystroke re-parses and re-groups the whole contents, and a paste decides how much that is. E.164 caps a number at 15 digits, so the longest text this field can itself produce is 21 characters (+, the calling code, and the grouped digits); 32 leaves half again as much room for the brackets, dashes and spaces people paste, and no number written the way people write them comes close.

Values below 21, or non-finite ones, cannot bound a real number and fall back to the default with a max-length-too-small warning.

32

optional name?: string;

Emits a hidden input carrying the E.164 value, readable by a native <form>.


optional onBlur?: (event) => void;

Fires when focus leaves the whole field, not when moving between its parts.

ParameterType
eventFocusEvent<HTMLElement>

void


optional onChange?: (value, details) => void;

Fires whenever the number changes, with the E.164 string and the details.

ParameterType
valuestring
detailsPhoneDetails

void


optional onCountryChange?: (iso2) => void;
ParameterType
iso2string

void


optional onFocus?: (event) => void;
ParameterType
eventFocusEvent<HTMLElement>

void


optional onWarn?: (warning) => void;

Called in development whenever a prop is rejected or coerced — see PhoneWarning. When omitted, the same warnings go to console.warn. The entire path is stripped from production builds.

ParameterType
warningPhoneWarning

void


optional placeholder?: string;

optional readOnly?: boolean;

optional renderCountry?: (state) => ReactNode;

Custom option contents.

ParameterType
statePhoneCountryState

ReactNode

flag, name and calling code

optional required?: boolean;

optional showValidity?: boolean;

Report, after the field has been left, whether the digits are a length the selected country actually uses. Off by default — a form that already shows its own errors does not want a second opinion inline.

This reflects possible, not full validity: it catches a typo’d or half-typed number, not an unassigned one. See the About page.

false

optional style?: CSSProperties;

optional validityLabel?: (state) => ReactNode;

Custom text for the showValidity message. Return '' to say nothing.

ParameterType
state{ country: | Country | undefined; details: PhoneDetails; possible: boolean; }
state.country| Country | undefined
state.detailsPhoneDetails
state.possibleboolean

ReactNode


optional value?: string;

Controlled value in E.164 ('+14155552671') or '' for empty.

One canonical format in and out — never the formatted display text, which changes with the country and would make the value a presentation detail.