Calm motion: animations on this site only fade, with no movement
PhoneInput
Country code select and phone number (E.164)
A country code select and a phone number in one field. The value is the full international number, so you can store and send it without more work. The component does not check that a number exists. For that, use a server-side library such as libphonenumber.
Basic
value: — · country: —
v-modelis the number as+and digits (E.164), for example+628123456789. It is empty until the person types a digit.v-model:countryis the region code of the selected country (ID).defaultCountrysets it while the value is empty.- People can type the number the way they say it. The component drops spaces and dashes, and removes a leading zero (
0812…becomes+62812…). The total never goes past 15 digits. - A value that comes from outside fills both parts. The longest calling code wins, so
+358…is Finland and not+3.+1is shared by the US and Canada, sov-model:countrydecides between them. countriesreplaces the list of 46 countries with{ code, dial }entries.blessCountriesis the default list.localesets the language of the country names (Intl.DisplayNames).- The number field sets
type="tel"andautocomplete="tel-national".labelsnames the two controls for screen readers: "Country code" and "Phone number".
Usage
ts
import { BlessPhoneInput } from "blessing-ui";API
Props
| Name | Type | Default | Description |
|---|---|---|---|
countries | BlessCountry[] | COUNTRIES | region codes and calling codes to offer. The default is a list of 46 countries. |
defaultCountry | string | "US" | the country shown when the value is empty |
locale | string | — | language of the country names (`Intl.DisplayNames`) |
size | "md" | "sm" | "lg" | "md" | |
disabled | boolean | — | |
labels | Partial<{ country: string; number: string; }> | — | |
modelValue | string | "" | the full number as `+` and digits (E.164), for example `+628123456789`. Empty when no digits. |
country | string | — | the region code of the selected country |
Events
| Name | Payload | Description |
|---|---|---|
update:modelValue | [value: string] | |
update:country | [value: string | undefined] |