Skip to content

Phone Field

Free

A field for a phone number and its country. Pick the country from a list with flags and search, and the number formats as you type.

  • Motion
  • React 19
  • Tailwind CSS 4

Added Nov 9, 2026 · MIT + Commons Clause

Playground

Loading the preview

Props

Put PhoneFieldGroup inside PhoneField, and name on PhoneFieldInput to submit E.164. onValueChange gets E.164 first, or null while the number is not possible.

contact-phone.tsx

PhoneField

<fieldset>
PropTypeDefaultDescription
disabledbooleanfalse
valuestring—The number as shown (controlled).
defaultValuestring""
onValueChange—Runs on every change with E.164 (or null while not possible) and every detail.
countrynull"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 (controlled). In international format the typed + code also sets it.
defaultCountry"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"—
onCountryChange—
phoneFormat"international""national""international"international (default): "+49 30 901820". national: "030 901820", the dial code in the trigger.
countriesreadonly CountryCode[]—Limit the list (in this order). One country: no list, no chevron.
metadataMetadataJsonPHONE_METADATAlibphonenumber-js metadata: min by default; max for exact valid and type.
check"possible""valid""possible"possible (default): the length fits. valid: the country ranges (use with max).
localestring—The language of the country names (Intl.DisplayNames). Default en, the same on server and client.
renderFlag—Your own flags (static imports for the server HTML, another set, or none: return null).
labels—The texts (translate them). {country} is the country name.
readOnlybooleanfalse
showErrorsbooleanfalseShow the error now, as after a submit.
requiredbooleanfalseAn empty number is an error (labels.required) after a blur or with showErrors.
...props<fieldset> attributes—Every other attribute goes to the <fieldset>, with a ref.

PhoneFieldLabel

<label>
PropTypeDefaultDescription
...props<label> attributes—Every other attribute goes to the <label>, with a ref.

PhoneFieldGroup

<div>
PropTypeDefaultDescription
rounded"default""full"—
size"default""lg""sm""xs"—
variant"dashed""default"—
classNamestring—
...props<div> attributes—Every other attribute goes to the <div>, with a ref.

PhoneFieldFlag

<div>
PropTypeDefaultDescription
localestring—The language of the name (Intl.DisplayNames). Default: the DisplayLocaleProvider locale.
popboolean—Pop the art in when code changes: scale 0.9 to 1 and a fade on the popup clock.
variant"circle""rectangle""square"—
countrynull"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, or null for the globe. Default: the country of the field.
...props<div> attributes—Every other attribute goes to the <div>, with a ref.

PhoneFieldCountry

<div>
PropTypeDefaultDescription
classNamestring—
align"block-end""block-start""inline-end""inline-start"—
...props<div> attributes—Every other attribute goes to the <div>, with a ref.

PhoneFieldInput

<div>
PropTypeDefaultDescription
namestring—Submit E.164 under this name (a hidden input).
classNamestring—
guideboolean—The ghost guide of the slots still to fill, while the input has focus. Default true.
rawNamestring—Also submit the raw value under this name (a hidden input), next to the shown one.
rejectFeedbackboolean—Nudge the field 2px when the mask rejects a key. Default true.
onReject—Runs when the mask rejects a key (a letter in a number, a 13th month).
refRef<HTMLInputElement>—
rounded"default""full"—
size"default""lg""sm""xs"—
...props<div> attributes—Every other attribute goes to the <div>.

PhoneFieldError

<p>
PropTypeDefaultDescription
...props<p> attributes—Every other attribute goes to the <p>, with a ref.
  • Use it to ask for a phone number from more than one country.
  • Use phoneFormat="national" to show the dial code in the trigger.
  • Use countries to limit the list. With one country, there is no list.
  • Use name on PhoneFieldInput to submit E.164 with a form.
  • For another fixed text format, such as a card number, use a Masked Input.
  • For a one-time code sent to the phone, use an Input OTP.
EnterorSpaceorArrow DownOn PhoneFieldCountry: opens the country list.
Arrow keysIn the list: moves through the countries.
EnterIn the list: picks the country.
EscapeCloses the country list.

PhoneFieldLabel names the number input, and the country list is a button with its own name.

PhoneFieldError shows after a blur or with showErrors.

Translate the texts with labels, and set the language of the country names with locale.

Open
popup · 150ms · ease-panel (0.2, 0.4, 0.2, 1) · fades in and scales from 95%
Close
popup-exit · 120ms · ease-out (0, 0, 0.2, 1)

Built with

Installs with Phone Field

  1. AddedPhone Field, with Combobox, Country Flag, Input Group, Masked Input.
Open the release