Phone field
A phone number field with a country picker, formatting and validity.
Valid number.
When to use
- Sign-up and contact forms that need international numbers.
- You want formatting as people type and a valid flag.
When not to use
- You only collect numbers for one country; a plain input with a pattern is lighter.
Installation
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.
API reference
PhoneField
15 props
parsePhone
0 props
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.
Keyboard
- β
- Moves to the next item or value.
- β
- Moves to the previous item or value.
- Enter
- Activates the focused control.
- Escape
- Closes or cancels, then returns focus to where it came from.
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.
Notes for AI
Give your coding assistant this page as Markdown instead of screenshots: the props, keyboard and examples in one file.
/docs/components/phone-field.mdThe index of every part is at /llms.txt.