PhoneInput

A phone number input with international country code selector, built on InputGroup.

Installation

pnpm add @wandercom/design-system-web

Usage

import { PhoneInput } from '@wandercom/design-system-web/ui/phone-input';

export function Example() {
  const [phone, setPhone] = useState('');

  return <PhoneInput defaultCountry="us" value={phone} onChange={setPhone} />;
}

Examples

Default

Basic phone input with country selector.

Loading example...

Small

Using the sm size variant.

Loading example...

With Label

Phone input paired with a label.

Loading example...

Disabled

Disabled state with a pre-filled value.

Loading example...

Custom Country List

Restrict the available countries using the countries prop. Use defaultCountries and parseCountry from react-international-phone to filter.

Loading example...
import { defaultCountries, parseCountry } from 'react-international-phone';

const northAmerica = defaultCountries.filter((c) =>
  ['us', 'ca'].includes(parseCountry(c).iso2)
);

<PhoneInput countries={northAmerica} defaultCountry="us" />

Props

value?:

string
Phone value in E.164 format (e.g. "+14155550123").

onChange?:

(value: string) => void
Called with E.164 phone string on change.

defaultCountry?:

CountryIso2
Default country ISO-2 code. Defaults to "us".

countries?:

CountryData[]
Restrict available countries. Defaults to all countries.

preferredCountries?:

CountryIso2[]
Countries pinned to the top of the dropdown.

size?:

"default" | "sm"
Size variant matching InputGroup sizes. Defaults to "default".

placeholder?:

string
Placeholder text for the phone number field. Defaults to "Phone number".

disabled?:

boolean
Disable the entire input. Defaults to false.

className?:

string
Additional CSS classes for the root InputGroup.

Keyboard Navigation

  • Tab - Move focus to the phone number input
  • Enter / Space on country button - Open country selector
  • / in dropdown - Navigate countries
  • Enter on country - Select and return focus to input
  • Escape - Close dropdown
  • Type in search field - Filter by country name or dial code

Accessibility

  • Country selector button has aria-label="Select country"
  • Flag images include country name as alt text
  • Dropdown search supports keyboard-only navigation
  • Focus is returned to the phone number input after country selection

Behavior

Country selector opens a searchable popover. Search by country name or dial code (e.g. "+44" or "united").

Preferred countries appear at the top of the dropdown list when specified.

E.164 output — the onChange callback always emits the full international number in E.164 format (e.g. +14155550123), suitable for storage and validation.

Dial code display — shown between the flag and the input, matching the primary text color.

Built on InputGroup — inherits size variants, border states, focus ring, and disabled styling from the design system's InputGroup component.

PhoneInput