Phone Input
International phone field with a country selector, emitting E.164.
Import
import { PhoneInput } from "@cooud-ui/ui";
npx cooud-ui add phone-input
Examples
API Reference
Generated from the component's exported types.
PhoneInputProps
Extends Omit< InputHTMLAttributes<HTMLInputElement>, "value" | "defaultValue" | "onChange" | "type" >
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | — | Controlled value as an E.164 string (e.g. `"+5511987654321"`). Pair with `onChange`. |
defaultValue | string | — | Initial E.164 (or bare national) value for uncontrolled usage. |
onChange | (value: string) => void | — | Called with the full E.164 string on every edit; empty string when no number is entered. |
defaultCountry | string | "BR" | ISO 3166-1 alpha-2 code selected on first render. Defaults to `"BR"`. |
countries | PhoneCountry[] | DEFAULT_PHONE_COUNTRIES | Overrides the built-in country list. Order controls the list order. |
invalid | boolean | false | Marks the field invalid (red border/ring + `aria-invalid`). |
searchPlaceholder | string | "Search country…" | Placeholder for the country search box inside the selector. |
emptyText | string | "No country found." | Message shown when no country matches the search. |
label | string | "Phone number" | Accessible name for the whole control and the number field. Defaults to `"Phone number"`. |
countryLabel | string | "Select country" | Accessible name for the country selector trigger. Defaults to `"Select country"`. |
contentClassName | string | — | Extra classes for the country selector popover. |
name | string | — | Name for a hidden input carrying the E.164 value, so the field submits inside a form. |