Skip to content
synccn

Phone Input

New

Country picker and a number field that formats as you type.

United States number

Installation

$ pnpm dlx shadcn@latest add @synccn/phone-input

First time in this project? Connect synccn with one command.

Usage

import { PhoneInput } from "@/components/ui/phone-input";<PhoneInput defaultCountry="US" onChange={({ e164 }) => …} />

API reference

Generated from the component's TypeScript types, so it always matches the code.

PhoneInput

Country picker plus a number field that formats as you type. onChange receives { country, digits, e164, valid }.

  • defaultCountry
    string

    Default "US"

    ISO code of the country selected first, e.g. US.

  • onChange
    (phone: { country: string; digits: string; e164: string; valid: boolean }) => void

    Called on every change.

  • className
    string

    Extra classes for the root element.

Dependencies

Read from the component's imports when the site builds. The CLI installs all of these for you.

Helpers

npm packages

Accessibility

From the source

Read from this component's code when the site builds, so it can't drift.

  • ARIA attributes: aria-invalid, aria-label
  • Labels are tied to their controls