Skip to content

Phone input

A phone field with a country picker, formatting as you type, and E.164 output.

InputsNew
npx shadcn@latest add @silicon-ui/phone-input

Installation

With the shadcn CLI

npx shadcn@latest add @silicon-ui/phone-input

Manually

  1. Install the dependencies

    npm install lucide-react motion
  2. Copy these files into your project

    • components/silicon-ui/phone-input/phone-input.tsx
    • components/silicon-ui/phone-input/phone-input.module.css

    Shared with other components. Skip any you already have.

    • components/silicon-ui/lib/fluid-hover.tsx
  3. Add the foundation, once per app, for the design and motion tokens

    npx shadcn@latest add @silicon-ui/silicon-foundation

Usage

usage.tsx
import { PhoneInput } from "@/components/silicon-ui/phone-input/phone-input";

API reference

PropTypeDefault
label*string—
hideLabelbooleanfalse
value

The number in E.164, such as "+14155550132". An empty string clears the field.

string—
defaultValuestring—
onValueChange

Fires on every edit with the E.164 number (empty for no digits or an unsupported draft) and its details.

(value: string, details: PhoneInputDetails) => void—
country

ISO code of the selected country.

string—
defaultCountry

ISO code used until someone picks a country or enters an international number.

string"US"
onCountryChange(iso: string) => void—
countries

Limit the picker to these ISO codes.

string[]—
preferredCountries

Pinned at the top of the picker under "Suggested".

string[]["US", "CA", "GB"]
descriptionstring—
error

Replaces the built-in validation message.

string—
validate

Show a message after blur when the number is incomplete. On by default.

booleantrue
disabledbooleanfalse
requiredboolean—
name

Adds a hidden input carrying the E.164 value for native form submission.

string—
idstring—
classNamestring—
onBlur(event: ReactFocusEvent<HTMLInputElement>) => void—

Also accepts the props of HTMLAttributes.

Dependencies

npm
lucide-reactmotion
Registry
silicon-motion-tokens