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.
Props
PhoneField 29 props
The text field style of both parts:
filledoroutlined. Filled by default, as the coreTextFieldandSelectbeside it are, so a form matches without a prop.Web density, 0 to -3: each step takes 4px off both fields (56px at 0, 44px at -3) and off the country list's rows. Left out, it follows the theme's or the nearest
ThemeScope's.The number in E.164 (
+447911123456), or''(controlled).The starting number in E.164 (uncontrolled); it also picks the starting country.
countrytype"AC" | "AD" | "AE" | "AF" | "AG" | "AI" | "AL" | "AM" | "AO" | "AR" | "AS" | "AT" | "AU" | "AW" | "AX" | "AZ" | "BA" | "BB" | "BD" | "BE" | "BF" | "BG" | "BH" | "BI" | "BJ" | "BL" | "BM" | "BN" | "BO" | "BQ" | "BR" | "BS" | "BT" | "BW" | "BY" | "BZ" | "CA" | "CC" | "CD" | "CF" | "CG" | "CH" | "CI" | "CK" | "CL" | "CM" | "CN" | "CO" | "CR" | "CU" | "CV" | "CW" | "CX" | "CY" | "CZ" | "DE" | "DJ" | "DK" | "DM" | "DO" | "DZ" | "EC" | "EE" | "EG" | "EH" | "ER" | "ES" | "ET" | "FI" | "FJ" | "FK" | "FM" | "FO" | "FR" | "GA" | "GB" | "GD" | "GE" | "GF" | "GG" | "GH" | "GI" | "GL" | "GM" | "GN" | "GP" | "GQ" | "GR" | "GT" | "GU" | "GW" | "GY" | "HK" | "HN" | "HR" | "HT" | "HU" | "ID" | "IE" | "IL" | "IM" | "IN" | "IO" | "IQ" | "IR" | "IS" | "IT" | "JE" | "JM" | "JO" | "JP" | "KE" | "KG" | "KH" | "KI" | "KM" | "KN" | "KP" | "KR" | "KW" | "KY" | "KZ" | "LA" | "LB" | "LC" | "LI" | "LK" | "LR" | "LS" | "LT" | "LU" | "LV" | "LY" | "MA" | "MC" | "MD" | "ME" | "MF" | "MG" | "MH" | "MK" | "ML" | "MM" | "MN" | "MO" | "MP" | "MQ" | "MR" | "MS" | "MT" | "MU" | "MV" | "MW" | "MX" | "MY" | "MZ" | "NA" | "NC" | "NE" | "NF" | "NG" | "NI" | "NL" | "NO" | "NP" | "NR" | "NU" | "NZ" | "OM" | "PA" | "PE" | "PF" | "PG" | "PH" | "PK" | "PL" | "PM" | "PR" | "PS" | "PT" | "PW" | "PY" | "QA" | "RE" | "RO" | "RS" | "RU" | "RW" | "SA" | "SB" | "SC" | "SD" | "SE" | "SG" | "SH" | "SI" | "SJ" | "SK" | "SL" | "SM" | "SN" | "SO" | "SR" | "SS" | "ST" | "SV" | "SX" | "SY" | "SZ" | "TA" | "TC" | "TD" | "TG" | "TH" | "TJ" | "TK" | "TL" | "TM" | "TN" | "TO" | "TR" | "TT" | "TV" | "TW" | "TZ" | "UA" | "UG" | "US" | "UY" | "UZ" | "VA" | "VC" | "VE" | "VG" | "VI" | "VN" | "VU" | "WF" | "WS" | "XK" | "YE" | "YT" | "ZA" | "ZM" | "ZW"The chosen country (ISO 3166-1 alpha-2); one dialling code can cover several.
defaultCountrytype"AC" | "AD" | "AE" | "AF" | "AG" | "AI" | "AL" | "AM" | "AO" | "AR" | "AS" | "AT" | "AU" | "AW" | "AX" | "AZ" | "BA" | "BB" | "BD" | "BE" | "BF" | "BG" | "BH" | "BI" | "BJ" | "BL" | "BM" | "BN" | "BO" | "BQ" | "BR" | "BS" | "BT" | "BW" | "BY" | "BZ" | "CA" | "CC" | "CD" | "CF" | "CG" | "CH" | "CI" | "CK" | "CL" | "CM" | "CN" | "CO" | "CR" | "CU" | "CV" | "CW" | "CX" | "CY" | "CZ" | "DE" | "DJ" | "DK" | "DM" | "DO" | "DZ" | "EC" | "EE" | "EG" | "EH" | "ER" | "ES" | "ET" | "FI" | "FJ" | "FK" | "FM" | "FO" | "FR" | "GA" | "GB" | "GD" | "GE" | "GF" | "GG" | "GH" | "GI" | "GL" | "GM" | "GN" | "GP" | "GQ" | "GR" | "GT" | "GU" | "GW" | "GY" | "HK" | "HN" | "HR" | "HT" | "HU" | "ID" | "IE" | "IL" | "IM" | "IN" | "IO" | "IQ" | "IR" | "IS" | "IT" | "JE" | "JM" | "JO" | "JP" | "KE" | "KG" | "KH" | "KI" | "KM" | "KN" | "KP" | "KR" | "KW" | "KY" | "KZ" | "LA" | "LB" | "LC" | "LI" | "LK" | "LR" | "LS" | "LT" | "LU" | "LV" | "LY" | "MA" | "MC" | "MD" | "ME" | "MF" | "MG" | "MH" | "MK" | "ML" | "MM" | "MN" | "MO" | "MP" | "MQ" | "MR" | "MS" | "MT" | "MU" | "MV" | "MW" | "MX" | "MY" | "MZ" | "NA" | "NC" | "NE" | "NF" | "NG" | "NI" | "NL" | "NO" | "NP" | "NR" | "NU" | "NZ" | "OM" | "PA" | "PE" | "PF" | "PG" | "PH" | "PK" | "PL" | "PM" | "PR" | "PS" | "PT" | "PW" | "PY" | "QA" | "RE" | "RO" | "RS" | "RU" | "RW" | "SA" | "SB" | "SC" | "SD" | "SE" | "SG" | "SH" | "SI" | "SJ" | "SK" | "SL" | "SM" | "SN" | "SO" | "SR" | "SS" | "ST" | "SV" | "SX" | "SY" | "SZ" | "TA" | "TC" | "TD" | "TG" | "TH" | "TJ" | "TK" | "TL" | "TM" | "TN" | "TO" | "TR" | "TT" | "TV" | "TW" | "TZ" | "UA" | "UG" | "US" | "UY" | "UZ" | "VA" | "VC" | "VE" | "VG" | "VI" | "VN" | "VU" | "WF" | "WS" | "XK" | "YE" | "YT" | "ZA" | "ZM" | "ZW"The country to start on, e.g. the visitor's. Else the first priority country.
Listed first, in this order, e.g. an app's main markets.
A flag (or any icon) for a country, shown in the country field and the list. None by default.
Locale for country names.
Helper text below the number. Replaced visually by the error when invalid.
Marks the number invalid. Without it, the field checks the number itself when it loses focus and shows
errorMessage(orlabels.invalid) for one that isn't valid.The error shown while invalid.
Marks the number required (an asterisk after the label, and form validation).
Disables both fields.
Shows the number and country without letting them change.
Submits the E.164 value under this name.
Focuses the number when the field mounts.
The number's
<input>id (as on the core's fields), so a<label for>or an error summary's#idlink reaches it.Ref to the root element (the group).
Ref to the number's input.
The number field's floating label, which also names the country field. Required unless
aria-labeloraria-labelledbyis given.
Events
Called with the number in E.164, possibly incomplete while typing, or
''.Called when the country changes: chosen from the list, or picked by a
+…number.
Text
The words it shows and announces, merged over the English defaults. A
LabelsProvidersets them for the whole app.The country field's name, e.g. "Country".
The search field in the country list.
Shown when no country matches the search.
The priority countries' group in the list.
The full list's group.
The error for a number that isn't valid for its country.
Names the number for screen readers when there's no visible
label, e.g. "Phone number".Identifies the element (or elements) that labels the current element.
One of
label,aria-labeloraria-labelledbyis required.
Classes for the root; they win over the defaults via
cn().Classes for each part, including the core fields inside.
The group holding both fields (the same element as
className).The country field's root (a searchable
Select).The country field's filled or outlined container.
The chosen country's dialling code (and flag) in the country field.
The country list's surface (the menu, or the list inside the sheet on phones).
The bottom sheet the country list opens in on phones.
The search field at the top of the country list.
Each country in the list.
Each section heading in the list ("Suggested countries", "All countries").
The number field's root (the core
TextField).The number field's filled or outlined container.
The number field's floating label.
The number's
<input>.The helper text below the number.
The error message below the number.
Inline styles for the root.
Also accepts the root element's HTML attributes (id, data-*, event handlers).
Spec status
Not part of Material Design 3: a Windmorph Pro component, built on M3's colour roles, type scale, shapes and motion. Its variants and configurations each link to a live example.
| Item | Status | Details |
|---|---|---|
| Variants: filled (default) and outlined | Built | Variant · Variants |
| Priority countries and a starting country | Built | Configuration · Signup |
| Invalid number | Built | Configuration · Variants |
| Flags | Built | Configuration · Flags |
| Required, read-only and disabled | Built | Configuration · States |
Country names in another language (locale) | Built | Configuration · States |
Density, 56 to 44px (density) | Built | Configuration · Density |
| A phone number at sign-up | Built | Use case · Signup |
| Built on the M3 text field and select | Extension | The number is a TextField, and the country a searchable Select that opens as the M3 menu on medium and larger windows and as a bottom sheet on compact ones. |
Variants: filled (default) and outlined
BuiltVariant · Variants
Priority countries and a starting country
BuiltConfiguration · Signup
Invalid number
BuiltConfiguration · Variants
Flags
BuiltConfiguration · Flags
Required, read-only and disabled
BuiltConfiguration · States
Country names in another language (
Builtlocale)Configuration · States
Density, 56 to 44px (
Builtdensity)Configuration · Density
A phone number at sign-up
BuiltUse case · Signup
Built on the M3 text field and select
ExtensionThe number is a
TextField, and the country a searchableSelectthat opens as the M3 menu on medium and larger windows and as a bottom sheet on compact ones.
M3 Expressive specs
- Shape
rounded-corner-extra-small- Variants
outlined, filled
Theming
- The phone field has no values of its own to override: its parts take the core's Text field, Select, search and menu tokens, so a theme for those reaches it. Its root is marked
data-tokens="wm-phone-field". - Like the core's fields, it is
filledby default, oroutlined. The country field is a Select, so it has the Text field's tokens in both variants: theoutlineor filled container, 2pxprimarywhen focused or open, anderrorwhen the number is invalid. - The search is the M3 search bar's field at 48px (M3's minimum touch target, so it doesn't dominate the 44px rows), with full corners,
surface-container-high, and the focus ring for keyboard focus only. - The list is the one Select and Autocomplete use: the M3 menu's
surface-container-lowpanel at elevation 2, with the chosen country intertiary-containerwith a check, and state layers for hover and keyboard focus. classNamesreaches every part: therootgroup; the country field'scountryroot,countryContainerandcountryValue; the list'spickersurface,pickerSheet(phones),pickerSearch,pickerOptionandpickerHeading; and the number'snumberroot,numberContainer,label,input(the real<input>),supportingTextanderrorText.