Skip to content
caliper ui docs

Pro

Phone field

A phone number field with a country picker, formatting and validity.

Pro
pnpm dlx shadcn@latest add @caliper/phone-field

Delivery contact

The courier texts this number on the day

Valid number.

Installs components/ui/phone-field.tsxDepends on lucide-reactMotion shared motion tokens

When to use

Use it for

  • Sign-up and contact forms that need international numbers.
  • You want formatting as people type and a valid flag.

Skip it when

  • You only collect numbers for one country; a plain input with a pattern is lighter.

Installation

terminal
pnpm dlx shadcn@latest add @caliper/phone-field

Adds its 3 files to components/ui/, each with its own stylesheet, and installs their packages. Pro installs with your access token, set up once per project. See Pro access. The first part also adds Caliper UI’s tokens; import them once as in Installation.

Usage

Import it from your copy of the source. The example behind the preview comes with the source. It is built from PhoneField and parsePhone.

example.tsx
import { PhoneField, parsePhone, phoneCountries } from "@/components/ui/phone-field"

The worked example comes with Pro

The 24-line example behind the preview opens here, ready to copy.

  • 626 Pro parts, blocks and page templates, all with source
  • $149 once, with lifetime updates. No renewal
  • A full refund within 14 days if it is not for you
Checking your licence…

API reference

PhoneField

component
PropTypeDefault
labelstring"Phone number"
valuestringβ€”
defaultValuestring""
countrystringβ€”
defaultCountrystring"US"
countriesreadonly string[]β€”
preferredCountriesreadonly string[]["US", "GB", "IN"]
descriptionstringβ€”
disabledbooleanβ€”
requiredbooleanβ€”
namestringβ€”
idstringβ€”
onValueChange((value: string, details: PhoneDetails) => void)β€”
onCountryChange((iso: string) => void)β€”
classNamestringβ€”

parsePhone

component

No props of its own; it accepts the native props of its root element.

phoneCountries

helper

A helper exported alongside the component, not a component.

Accessibility

It exposes listbox and option semantics, with aria-label, aria-expanded, aria-controls, aria-hidden, aria-invalid and aria-describedby kept in step with state.

KeyBehaviour
↓Moves to the next item or value.
↑Moves to the previous item or value.
EnterActivates the focused control.
EscapeCloses or cancels, then returns focus to where it came from.

Motion

Transitions use the shared duration and easing tokens. Under prefers-reduced-motion those tokens collapse to instant and travel distances go to zero, so state changes still happen without movement.

All Money and phone examples