PhoneInput

Phone input that stores E.164 and renders a country selector plus a national-format text input. Uses libphonenumber-js for parsing.

Installation

pnpm dlx shadcn@latest add @shadmin/phone-input

Usage

import { PhoneInput } from '@/components/admin';
 
<PhoneInput source="phone" />
<PhoneInput source="phone" defaultCountry="GB" />
<PhoneInput source="phone" allowedCountries={["US", "CA", "MX"]} />

Props

PropRequiredTypeDefaultDescription
sourceRequiredstring-Form field name
defaultCountryOptionalCountryCode"US"Country used when value is empty
allowedCountriesOptionalreadonly CountryCode[]AllRestrict selectable countries
labelOptionalstring | falseInferredCustom label, false to hide
helperTextOptionalReactNode-Helper text
disabledOptionalbooleanfalseDisable both controls
defaultValueOptionalstring-Initial E.164 value
validateOptionalValidator | Validator[]-Validation
classNameOptionalstring-CSS class

Storage format

E.164 strings. The component parses every keystroke via AsYouType for live formatting in the visible input; the form state holds canonical E.164.

Dependency

libphonenumber-js (~140KB). Tree-shakes when only parsePhoneNumber and AsYouType are imported.