Phone Input
International phone field with a country selector, emitting E.164.
Import
import { PhoneInput } from "@cronus-ui/ui";
npx cronus-ui add phone-input
Examples
.cronus
The same component declared in Cronus. Emitted at build time from the audit fixtures — the kernel renders it as HTML with no React.
default.cronus
app "audit-fixtures" {
port 5176
}
style {
preset aurora
theme dark
}
component PhoneInputDefault layout:inline style:phone-input {
value:"+5511987654321"
aria-label:"Phone number"
label "Phone number"
}
page "/audit/phone-input/default" type:custom {
use PhoneInputDefault
}
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 `onValueChange`. |
defaultValue | string | — | Initial E.164 (or bare national) value for uncontrolled usage. |
onValueChange | (value: string) => void | — | Called with the full E.164 string on every edit; empty string when no number is entered. |
onChange | (value: string) => void | — | Called when the value changes. |
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. |
placeholder | string | — | Placeholder shown when the value is empty. |
disabled | boolean | — | Disables pointer and keyboard interaction. |
required | boolean | — | Marks the control as required. |
className | string | — | Additional class names merged onto the root. |