Meridianby Commenda
Components

AddressInput

A postal address in one layout for every country.

A postal address in one layout for every country. Start typing in line 1 and pick a suggestion, or fill the fields by hand. Nothing moves when the country changes. Every field is 40 high with a 16 value and a 14 label. On the site it appears on partner and event forms that ship something.

Mailing address
United States
(optional)
Mailing address
United States
(optional)
New York

Usage

Example.tsx
import { AddressInput } from "@commenda/meridian/ui/address-input";

<AddressInput label="Mailing address" value={address} onValueChange={setAddress} />;

One layout for every country

Country, two address lines, then City beside Postal code, and State or region on its own row, wide enough for long region names. The same fields in the same places whatever the country; only the examples and the validation follow it. Line 2 is optional.

Mailing address
United States
(optional)
Mailing address
United States
(optional)
New York

Suggestions

Typing in line 1 opens suggestions over the fields below it, so nothing is pushed down: the street as the label, then city, region, code and country, a pin before each. Picking one fills every field in place for review. Wire it with suggestionsConfig to your address lookup.

Errors

Each field shows its own error under it, after the person leaves the field. The postal code error uses the country’s word for it.

Mailing address
United States
(optional)
New York
Use 5 digits.

Anatomy

Every field is an Input: 40 high, radius 8, 16 value, 14 label, 16 between rows and 12 between the two columns.

API reference

PropTypeDescription
labelConditionalstringFrom Pathfinder.
hideLabelbooleanFrom Pathfinder.
aria-labelConditionalstringFrom Pathfinder.
valueConditionalAddressValueView fieldsFrom Pathfinder.
onValueChangeConditional(value: AddressValue) => voidFrom Pathfinder.
defaultValueAddressValueView fieldsFrom Pathfinder.
idstringFrom Pathfinder.
namestringFrom Pathfinder.
formstringFrom Pathfinder.
classNamestringFrom Pathfinder.
descriptionstringFrom Pathfinder.
aria-describedbystringFrom Pathfinder.
readOnlybooleanFrom Pathfinder.
disableConfigObjectView fieldsFrom Pathfinder.
countryConfigAddressCountryConfigView fieldsFrom Pathfinder.
regionConfigObjectView fieldsFrom Pathfinder.
requiredFieldsreadonly ("country" | "addressLine1" | "city" | "region" | "postalCode")[]From Pathfinder.
fieldErrorsPartial<Record<keyof AddressValue, string>>From Pathfinder.
suggestionsConfigAddressSuggestionsConfigView fieldsFrom Pathfinder.
valueObject fields
FieldTypeDescription
countryRequiredstring
addressLine1Requiredstring
addressLine2Requiredstring
cityRequiredstring
regionRequiredstring
postalCodeRequiredstring
defaultValueObject fields
FieldTypeDescription
countryRequiredstring
addressLine1Requiredstring
addressLine2Requiredstring
cityRequiredstring
regionRequiredstring
postalCodeRequiredstring
disableConfigObject fields
FieldTypeDescription
isDisabledRequiredboolean
reasonstring
countryConfigObject fields
FieldTypeDescription
allowedCountriesreadonly ("AD" | "AE" | "AF" | "AG" | "AL" | "AM" | "AO" | "AR" | "AT" | "AU" | "AZ" | "BA" | "BB" | "BD" | "BE" | "BF" | "BG" | "BH" | "BI" | "BJ" | "BN" | "BO" | "BR" | "BS" | "BT" | "BW" | "BY" | "BZ" | "CA" | "CD" | "CF" | "CG" | "CH" | "CI" | "CK" | "CL" | "CM" | "CN" | "CO" | "CR" | "CU" | "CV" | "CY" | "CZ" | "DE" | "DJ" | "DK" | "DM" | "DO" | "DZ" | "EC" | "EE" | "EG" | "ER" | "ES" | "ET" | "FI" | "FJ" | "FM" | "FR" | "GA" | "GB" | "GD" | "GE" | "GH" | "GM" | "GN" | "GQ" | "GR" | "GT" | "GW" | "GY" | "HN" | "HR" | "HT" | "HU" | "ID" | "IE" | "IL" | "IN" | "IQ" | "IR" | "IS" | "IT" | "JE" | "JM" | "JO" | "JP" | "KE" | "KG" | "KH" | "KI" | "KM" | "KN" | "KR" | "KW" | "KY" | "KZ" | "LA" | "LB" | "LC" | "LI" | "LK" | "LR" | "LS" | "LT" | "LU" | "LV" | "LY" | "MA" | "MC" | "MD" | "ME" | "MG" | "MH" | "MK" | "ML" | "MM" | "MN" | "MR" | "MT" | "MU" | "MV" | "MW" | "MX" | "MY" | "MZ" | "NA" | "NE" | "NG" | "NI" | "NL" | "NO" | "NP" | "NR" | "NZ" | "OM" | "PA" | "PE" | "PG" | "PH" | "PK" | "PL" | "PR" | "PT" | "PW" | "PY" | "QA" | "RO" | "RS" | "RU" | "RW" | "SA" | "SB" | "SC" | "SD" | "SE" | "SG" | "SI" | "SK" | "SL" | "SM" | "SN" | "SO" | "SR" | "SS" | "ST" | "SV" | "SY" | "SZ" | "TD" | "TG" | "TH" | "TJ" | "TL" | "TM" | "TN" | "TO" | "TR" | "TT" | "TV" | "TW" | "TZ" | "UA" | "UG" | "US" | "UY" | "UZ" | "VA" | "VC" | "VE" | "VG" | "VN" | "VU" | "WS" | "YE" | "ZA" | "ZM" | "ZW")[]
excludedCountriesreadonly ("AD" | "AE" | "AF" | "AG" | "AL" | "AM" | "AO" | "AR" | "AT" | "AU" | "AZ" | "BA" | "BB" | "BD" | "BE" | "BF" | "BG" | "BH" | "BI" | "BJ" | "BN" | "BO" | "BR" | "BS" | "BT" | "BW" | "BY" | "BZ" | "CA" | "CD" | "CF" | "CG" | "CH" | "CI" | "CK" | "CL" | "CM" | "CN" | "CO" | "CR" | "CU" | "CV" | "CY" | "CZ" | "DE" | "DJ" | "DK" | "DM" | "DO" | "DZ" | "EC" | "EE" | "EG" | "ER" | "ES" | "ET" | "FI" | "FJ" | "FM" | "FR" | "GA" | "GB" | "GD" | "GE" | "GH" | "GM" | "GN" | "GQ" | "GR" | "GT" | "GW" | "GY" | "HN" | "HR" | "HT" | "HU" | "ID" | "IE" | "IL" | "IN" | "IQ" | "IR" | "IS" | "IT" | "JE" | "JM" | "JO" | "JP" | "KE" | "KG" | "KH" | "KI" | "KM" | "KN" | "KR" | "KW" | "KY" | "KZ" | "LA" | "LB" | "LC" | "LI" | "LK" | "LR" | "LS" | "LT" | "LU" | "LV" | "LY" | "MA" | "MC" | "MD" | "ME" | "MG" | "MH" | "MK" | "ML" | "MM" | "MN" | "MR" | "MT" | "MU" | "MV" | "MW" | "MX" | "MY" | "MZ" | "NA" | "NE" | "NG" | "NI" | "NL" | "NO" | "NP" | "NR" | "NZ" | "OM" | "PA" | "PE" | "PG" | "PH" | "PK" | "PL" | "PR" | "PT" | "PW" | "PY" | "QA" | "RO" | "RS" | "RU" | "RW" | "SA" | "SB" | "SC" | "SD" | "SE" | "SG" | "SI" | "SK" | "SL" | "SM" | "SN" | "SO" | "SR" | "SS" | "ST" | "SV" | "SY" | "SZ" | "TD" | "TG" | "TH" | "TJ" | "TL" | "TM" | "TN" | "TO" | "TR" | "TT" | "TV" | "TW" | "TZ" | "UA" | "UG" | "US" | "UY" | "UZ" | "VA" | "VC" | "VE" | "VG" | "VN" | "VU" | "WS" | "YE" | "ZA" | "ZM" | "ZW")[]
regionConfigObject fields
FieldTypeDescription
optionsRequiredreadonly ChoiceOption[]
suggestionsConfigObject fields
FieldTypeDescription
itemsRequiredreadonly AddressSuggestion[]
isLoadingRequiredboolean
errorstring
resultsQueryRequiredstringQuery that produced the supplied items; stale results cannot be selected.
onQueryChangeRequired(query: string) => void

Best practices

  • Keep the layout fixed: changing the country never adds, removes or moves fields.
  • Default the country to the visitor’s location and let people change it. Countries lead with their flag.
  • Offer suggestions in line 1, and let people ignore them and type every field.
  • Open suggestions over the form, never between fields.
  • Make line 2 optional. Never split house number, street and unit into separate fields.
  • Validate postal codes for the chosen country and say so in its words ("Enter a valid PIN code").
  • In code, each field carries its autocomplete attribute: country, address-line1, address-line2, address-level2, address-level1, postal-code. Map each to its HubSpot property.
  • Source: Pathfinder AddressInput. Meridian makes every field 40 tall with a 16 value and a 14 label.

On this page