Calm motion: animations on this site only fade, with no movement
Address fields
Address fields whose order and names follow the country
Asks for a postal address in the form that people of each country know. For example, a US address has a state and a ZIP code, and a Japanese address starts with the postal code. For one line of free text, use the input.
Basic
Change the country to see the fields move. {"country":"ID","line1":"Jl. Braga No. 41","city":"Bandung","region":"Jawa Barat"}
v-modelis the address:countryas an ISO code, andline1,line2,city,region, andpostal.countriessets the list of countries, as codes. Their names come fromIntl.DisplayNamesin thelocale(default English).- A small table gives the rows of fields for Indonesia, the US, Canada, the UK, Germany, France, and Japan. Other countries get a common form.
formatsadds a country or changes one, with its rows and the names of its region and postal code. - Each field has the right
autocompletevalue, so the browser can fill in a saved address. All fields but the second line are required. - The fields are native fields in a group named by
label(default "Address"). Change the names withlabelsor a label pack:country,line1,line2,city,state,province,prefecture,county,zip,postcode, andpostal.
Usage
ts
import { BlessAddressFields } from "blessing-ui";API
Props
| Name | Type | Default | Description |
|---|---|---|---|
countries | string[] | ["ID", "US", "GB", "DE", "FR", "JP", "CA"] | the countries to offer, as ISO codes |
formats | Record<string, BlessAddressFormat> | — | more formats, or changes to the built-in ones, by country code |
locale | string | "en" | the language of the country names, for example `id` |
label | string | "Address" | names the group of fields |
labels | Partial<{ country: string; line1: string; line2: string; city: string; state: string; province: string; prefecture: string; county: string; zip: string; postcode: string; postal: string; }> | — | |
modelValue | BlessAddress | { country: "ID" } |
Events
| Name | Payload | Description |
|---|---|---|
update:modelValue | [value: BlessAddress] |