Skip to content
THE COMPONENT LIBRARY
Skip to content

Component reference

PhoneInput

Choose a calling code and enter a contact number.

Preview

Live preview

Changes apply to this preview only.

Security contact

The country selector and the national field share one E.164 value. FormError is wired through aria-describedby.

Used for sign-in codes only.

Width adapts to the available space

More examples

Different configurations and compositions using the real Pimolu API. Each preview runs independently and follows the site appearance.

Countries and formatting

The country drives the dial prefix and the national pattern. An international value is matched to its country automatically.

Open preview

Sizes

sm, md and lg match the other text controls.

Open preview

Controlled value and country

Both the number and the country can be controlled. Selecting another country immediately re-emits the same national digits with the new dial code.

Open preview

Usage

Country selection and formatting do not prove that a phone number exists or is reachable.

API reference

Generated from the public TypeScript declarations. Native HTML attributes are inherited where the component extends them; this reference includes Pimolu props and selected common native attributes.

PimoluPhoneCountry

Type source
PimoluPhoneCountry public API
NameTypeDefaultDescription
codeRequiredstring—ISO 3166-1 alpha-2 code, used as the option value.
nameRequiredstring—Human-readable country name.
dialCodeRequiredstring—International dialling code, without the leading "+".
patternstring | undefined—Optional national pattern. `9` is a digit, every other character is a literal. Longer numbers keep their extra digits after the pattern.
codeRequired

string

No default extracted.

ISO 3166-1 alpha-2 code, used as the option value.

nameRequired

string

No default extracted.

Human-readable country name.

dialCodeRequired

string

No default extracted.

International dialling code, without the leading "+".

pattern

string | undefined

No default extracted.

Optional national pattern. `9` is a digit, every other character is a literal. Longer numbers keep their extra digits after the pattern.

PimoluPhoneInputProps

Type source
PimoluPhoneInputProps public API
NameTypeDefaultDescription
valuestring | undefined—Controlled phone number, preferably E.164 (`+14155551234`). A national number is also accepted and read with the selected country.
defaultValuestring | undefined—Initial phone number when uncontrolled.
onValueChange((value: string) => void) | undefined—Called with the next E.164 value, or "" when the field is empty.
countrystring | undefined—Controlled ISO country code (for example "FR").
defaultCountrystring | undefined"US"Initial country when uncontrolled. Defaults to "US".
onCountryChange((country: PimoluPhoneCountry) => void) | undefined—Called when the country selector changes.
countriesPimoluPhoneCountry[] | undefined—Replace the built-in country list.
countryLabelstring | undefined"Country"Accessible name of the country selector. Defaults to "Country".
labelReactNode—Visible label, associated with the national number input.
helperTextReactNode—Supporting text below the field.
errorMessageReactNode—Error text, replacing the helper text.
invalidboolean | undefinedfalseInvalid state without an error message.
sizePimoluPhoneInputSize | undefined"md"Visual size. Defaults to "md".
fullWidthboolean | undefinedfalseStretch to the parent width.
containerClassNamestring | undefined—Class applied to the outer field.
classNamestring | undefined—Standard React/HTML attribute.
styleCSSProperties | undefined—Standard React/HTML attribute.
aria-labelstring | undefined—Defines a string value that labels the current element.
childrenReactNode—Standard React/HTML attribute.
onClickMouseEventHandler<HTMLInputElement> | undefined—Standard React/HTML attribute.
disabledboolean | undefinedfalseStandard React/HTML attribute.
namestring | undefined—Standard React/HTML attribute.
requiredboolean | undefinedfalseStandard React/HTML attribute.
value

string | undefined

No default extracted.

Controlled phone number, preferably E.164 (`+14155551234`). A national number is also accepted and read with the selected country.

defaultValue

string | undefined

No default extracted.

Initial phone number when uncontrolled.

onValueChange

((value: string) => void) | undefined

No default extracted.

Called with the next E.164 value, or "" when the field is empty.

country

string | undefined

No default extracted.

Controlled ISO country code (for example "FR").

defaultCountry

string | undefined

Default: "US"

Initial country when uncontrolled. Defaults to "US".

onCountryChange

((country: PimoluPhoneCountry) => void) | undefined

No default extracted.

Called when the country selector changes.

countries

PimoluPhoneCountry[] | undefined

No default extracted.

Replace the built-in country list.

countryLabel

string | undefined

Default: "Country"

Accessible name of the country selector. Defaults to "Country".

label

ReactNode

No default extracted.

Visible label, associated with the national number input.

helperText

ReactNode

No default extracted.

Supporting text below the field.

errorMessage

ReactNode

No default extracted.

Error text, replacing the helper text.

invalid

boolean | undefined

Default: false

Invalid state without an error message.

size

PimoluPhoneInputSize | undefined

Default: "md"

Visual size. Defaults to "md".

fullWidth

boolean | undefined

Default: false

Stretch to the parent width.

containerClassName

string | undefined

No default extracted.

Class applied to the outer field.

className

string | undefined

No default extracted.

Standard React/HTML attribute.

style

CSSProperties | undefined

No default extracted.

Standard React/HTML attribute.

aria-label

string | undefined

No default extracted.

Defines a string value that labels the current element.

children

ReactNode

No default extracted.

Standard React/HTML attribute.

onClick

MouseEventHandler<HTMLInputElement> | undefined

No default extracted.

Standard React/HTML attribute.

disabled

boolean | undefined

Default: false

Standard React/HTML attribute.

name

string | undefined

No default extracted.

Standard React/HTML attribute.

required

boolean | undefined

Default: false

Standard React/HTML attribute.

Accessibility

  • Label the country selector and number separately, and preserve telephone autocomplete.
Read the accessibility guide →