Skip to contentKino
Skip to Content

Phone input

A phone number with its country. A button with the flag and dial code opens a searchable list of countries, the number is formatted as it is typed, and the form gets it in E.164.

npx shadcn add https://kinoui.com/r/phone-input.json
Share on

Examples

Turn on two-step sign-in

Each time you sign in on a new device, Kino texts you a code.

Standard text message rates may apply.

Default

Pick a country and type the number: it is formatted as you go, and the form gets it in E.164.

Copy a number above and paste it here.

Pasting

A number pasted or autofilled with its code, or with an exit code such as 00, moves the country to it.

Value
+12025550147
Country
US

Controlled

Own value and country, such as a number saved on an account.

Kino’s support team calls back in Europe only.

Countries

Offer only the countries you serve with countries.

Installation

npx shadcn@latest add https://kinoui.com/r/phone-input.json
Files
lib/refs.tslib/reduce-motion.tscomponents/kino/input.tsxcomponents/kino/textarea.tsxlib/resize.tslib/swap.tsxcomponents/kino/spinner.tsxcomponents/kino/button.tsxcomponents/kino/input-group.tsxlib/scroll.tslib/popup.tslib/glide.tsxcomponents/kino/tooltip.tsxlib/cut.tsxcomponents/kino/label.tsxcomponents/kino/separator.tsxlib/run-progress.tslib/highlight.tslib/menu.tsxcomponents/kino/select.tsxlib/filter-list.tsxlib/chip.tsxlib/flow.tscomponents/kino/combobox.tsxlib/field-control.tsxlib/addon-picker.tsxlib/countries.tsxlib/phone-number.tslib/dates.tscomponents/kino/phone-input.tsx
Packages
@base-ui/reactclass-variance-authoritycountry-flag-iconslibphonenumber-js

New to Kino? Installation covers what your project needs first and the @kino namespace.

API reference

Props

PropTypeDefaultDescription
valuestringNoneThe number in E.164, such as +442079460958, or "". While it is being typed it is the digits so far, such as +44207.
defaultValuestringNoneThe number at first, when you don’t own value.
onValueChange(value: string) => voidNoneCalled with the new number in E.164 as it is typed, pasted or its country changes.
countryCountryCodeNoneThe country, as an ISO 3166-1 code such as GB. A value with another country’s code shows that country instead.
defaultCountryCountryCode'US'The country at first, when you don’t own country.
onCountryChange(country: CountryCode) => voidNoneCalled when the person picks a country, or types or pastes a number that belongs to another one.
countriesreadonly CountryCode[]NoneThe countries the list offers. Every country by default.
localestringNoneThe language of the countries’ names. The browser’s by default.
labelstring'Country'What the button picks, in its name: “Country: United Kingdom (+44)”.
searchPlaceholderstring'Search countries'The list’s search, as a placeholder and its name.
placeholderstringNoneAn example number for the country, by default.

Data attributes

AttributeOnDescription
data-slot="phone-input"PhoneInputThe group, for styles of your own.

Accessibility

  • The country button is named for the pick, such as “Country: United Kingdom (+44)”, so a screen reader and speech control hear what it shows.
  • The list is a combobox with a search: arrow keys move through it, Enter picks, and Escape closes it and returns to the button. A pick sends focus straight to the number.
  • The number is a tel input with autocomplete="tel", so phones show a keypad and browsers fill a saved number, which the field reads with its code.
  • Backspace next to a space or bracket deletes the digit beyond it, and the caret stays after the same digit as the number is regrouped.
  • A number that isn’t whole fails the field’s check with “Enter the whole phone number.”, which FieldError match="customError" shows.
  • A disabled Field disables the button too, and a read-only one keeps its list shut. The number reads left to right in every language.