Address Picker
Search provinces and wards in a local dataset.
Preview
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 address-pickerUsage and variants
Snapshot v5.2.0 covers 34 provincial and 3,321 commune-level units through 20 September 2026. Changing province clears the ward. Historical three-level addresses require a separate crosswalk.
<AddressPicker label="Tỉnh thành" wardLabel="Phường xã" />For an audited historical crosswalk, supply legacyDefaultValue and legacyCrosswalk. Keys use province/district/ward codes separated by slashes. Each mapped destination must exist in the loaded snapshot.
Dataset sources and versionAPI
| Prop | Type | Behavior |
|---|---|---|
value, defaultValue | Address | Controlled value or initial uncontrolled value. |
onValueChange | (value) => void | Receives the next value; connect it to form state or React Hook Form Controller. |
label, name, disabled, className | string, string, boolean, string | Visible label, form name, disabled state and CSS class. |
entries | Province[] | Alternate versioned directory. |
value | Address | Province and ward codes as strings. |
wardLabel | string | Second field label. |
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.
An empty search announces No matches. Selecting a different province clears the ward; both selectors support keyboard search.