Ballmac UI home

Phone Input

A native dialing-code selector paired with a telephone field that preserves the user’s formatting.

Contact number

We will only use this for account recovery.

Installation

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

Usage

import { PhoneInput } from "@/components/ballmac/phone-input"

The full example is in the Code tab above.

Examples

States and variants

International contact

API reference

PropTypeDefault
value

National number, controlled by the parent. Formatting is preserved.

string—
defaultValue

Initial national number when uncontrolled.

string""
onValueChange

Called with the edited national number.

(value: string) => void—
countryCode

Controlled international dialing prefix.

string—
defaultCountryCode

Initial dialing prefix when uncontrolled.

string"+1"
onCountryCodeChange

Called when the dialing prefix changes.

(code: string) => void—
countries

Dialing prefixes available in the menu.

PhoneCountry[]defaultCountries
label

Accessible name of the number field.

string—
countryCodeName

Name of the separate country-code form field.

string—

Also accepts the standard attributes of its root element.

Accessibility

KeyAction
Arrow Up / DownChanges the native dialing-code selection
TabMoves to the telephone field

Use with AI

A native dialing-code selector paired with a telephone field that preserves the user’s formatting. With the shadcn MCP server set up (guide), ask your agent:

Add the Ballmac UI Phone Input (@ballmac/phone-input) to this project with the shadcn MCP, then use it where it fits.

Use it for

  • Collect a contact number with a dialing prefix
  • Edit a national number without forced formatting

Not for

  • Use input type tel when a country selector is unnecessary

Registry JSON: https://ui.ballmac.com/r/phone-input.json

Credits

Free to use in personal and commercial projects.

npm
None