Phone field
ProA phone number with a searchable country picker; formats as typed and reports E.164. Not an M3 component (@windmorph/react-pro).
import { PhoneField } from '@windmorph/react-pro';Part of Windmorph Pro, paid components on the free core, not on sale yet. See the Pro guide for what it includes and to register interest.
Keyboard
| Key | Action | Where |
|---|---|---|
| Tab | Moves focus to the country field, then to the number. | |
| Enter or Space or Arrow Down or Arrow Up | Open the country list.On the country field | On the country field |
| Arrow Left or Arrow Right | Choose the previous or next country without opening the list.On the country field | On the country field |
| A letter | Chooses the next country whose name starts with it, without opening the list.On the country field | On the country field |
| Arrow Down or Arrow Up | Move through the countries while focus stays in the search.In the country list | In the country list |
| Enter | Chooses the highlighted country and closes the list.In the country list | In the country list |
| Escape | Clears the search, then closes the list.In the country list | In the country list |
- Type in the search to filter by name (accents ignored), ISO code or dialling code: "thai", "TH" and "66" all find Thailand.
- The number is a plain text field: typing, paste and the browser's own keys work as usual. A pasted or autofilled
+…number picks its country.
Screen reader
- Role
- A
groupof two fields side by side: the country field is aSelecttrigger (buttonwitharia-haspopup="dialog") and the number is a text field (input type="tel"). - Accessible name
- The group is named by
label, or byaria-labeloraria-labelledbywithout one, and its number takes the same name. The country field is named by the chosen country with its dialling code as shown, thenlabels.country("United Kingdom, +44 Country"), so its name contains the visible code (WCAG 2.5.3). - States announced
- Both fields are marked invalid together.
disableddisables both;readOnlymakes the number read-only and keeps the country field enabled, showing its country without opening.requiredapplies to the number. The supporting text and the error describe the number.
- Each country in the list is an option read as its name and dialling code. The suggested and all-countries groups are named by
labels.suggestedandlabels.allCountries. - When nothing matches the search, the list says
labels.noResults. - Without
invalid, the field checks the number when it loses focus; an invalid one showserrorMessage(orlabels.invalid) in analertregion, so it is announced.
Focus
- On medium windows and up the list opens in a menu under the field with the search focused. On compact windows it opens in a bottom sheet with the list first, so the on-screen keyboard doesn't cover it.
- After a choice or Escape, focus returns to the country field, and the number is next in the Tab order. A press outside the list closes it and lets focus go.
- Both fields show M3's text field focus state.
Touch target
- Both fields are 56px tall at density 0, down to 44px at -3 (
density, or the theme's); the country list's rows lose 4px a step too. The search in the list stays 48px tall. - The field is 20rem wide (at least 320px), so larger text grows it instead of cutting the label short.
Motion
The country field's arrow turns as the list opens; under reduced motion it flips at once. The menu then only fades, and options don't slide as the search filters them.
What you need to do
- Give it a visible
label("Phone number"). Where the page already shows one, pointaria-labelledbyat it; usearia-labelonly where a visible label is impossible. - Pass
labelsfrom your translations: the country field's name, the search, the group names, the empty message and the error. - Pass
defaultCountry(the visitor's, when known) andpriorityCountries, so most people find their country at the top. - When the server rejects a number, set
invalidand anerrorMessagethat says how to fix it.