vn/ui / Docs / Components

Phone Input

Format and normalize Vietnamese phone numbers.

Preview

★ VN
E.164+84912345678

The Code tab uses the common @/* alias. Import the copied file from the directory in vnui.json if your app uses a different path.

Installation

Initialize vn/ui in your app, then add this component.

npx @naminc/vnui@latest add phone-input

Usage and variants

Local and international forms use the same normalization helper. It checks the format of mobile and geographic numbers. Subscriber activity requires a separate service.

<PhoneInput defaultValue="+84912345678" />

API

PropTypeBehavior
value, defaultValuestringControlled value or initial uncontrolled value.
onValueChange(value) => voidReceives the next value; connect it to form state or React Hook Form Controller.
label, name, disabled, classNamestring, string, boolean, stringVisible label, form name, disabled state and CSS class.
onNormalizedChange(value: string | null) => voidReceives E.164 or null.
validate(text: string) => booleanOverride the format check.

Use value and onValueChange for controlled fields, including React Hook Form Controller. Use defaultValue for standalone fields. label, name, disabled and className customize the field.

Accessibility

Fields have visible labels and keyboard focus. Searchable selectors support typing, arrow keys, Enter and Escape; date controls use browser keyboard behavior.

A malformed number shows a linked error after blur or form validation. onNormalizedChange returns null until the format is valid.