Skip to content
← Inventory

PhoneInput

Phone number input with an integrated country selector, built on react-phone-number-input; emits E.164-formatted values via onChange.

🌐

Usage

import { E164Number, PhoneInput, PhoneInputProps } from "@desk/ui/components/phone-input";

Best practices

  • onChange emits an E.164 string (e.g. +15550000000) or undefined while the number is incomplete/cleared β€” store that shape, don't reformat the raw text yourself.

  • Set defaultCountry (ISO alpha-2, default "US") for the initial calling code; the integrated country selector then lets users switch.

  • Validate the emitted E.164 value (e.g. via react-phone-number-input's isValidPhoneNumber) rather than regex-matching the display text.

Props

PropTypeDefaultDescription
radius"rounded" | "full" | null | undefined
size"base" | "2xs" | "xs" | "sm" | "lg" | "xl" | "2xl" | "3xl" | null | undefined
valuestring

Current phone number value

onChange(value: E164Number | undefined) => void

Callback when phone number changes

hasErrorboolean

Show error styling

classNamestring

Additional class name for the container

disabledboolean

Disabled state

defaultCountryimport("libphonenumber-js/core").CountryCode

Default country code (e.g., "US", "GB"). Defaults to "US".

placeholderstring

Placeholder text

testIdstring

Also exports

  • typeE164Number
  • typePhoneInputProps

Composition

Builds on

CountrySelect