# Address

import SearchableTable from "@components/content/SearchableTable";

The Address object uses a comprehensive format that can handle addresses from
around the world. The address fields used depend on the country conventions.
For example, in Great Britain, `city` is `post_town`. In the United States, the
top-level administrative unit used in addresses is `state`, whereas in Chile
it's `region`.

The address structure is based on
[libaddressinput](https://github.com/google/libaddressinput) used by Android
and Chromium.

Whether an address is valid depends on whether the locally required fields are
present. For example:

- **Germany**: requires `street_address`, `post_code`, and `city`
- **United States**: uses `state` for the top-level administrative unit
- **Great Britain**: uses `post_town` instead of `city`
- **Chile**: uses `region` for the top-level administrative unit
- **Ireland**: uses `eircode` instead of `post_code`

## Core Address Fields

- **`country`**: The two letter country code formatted according to [ISO3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2). Example: `["DE", "GB"]`
- **`street_address`**: The address lines, with each element representing one line. Example: `["Paul-Linke-Ufer 39-40", "2. Hinterhof"]`

## Post Code

A postal code included in a postal address for the purpose of sorting mail.

The following fields are used for post code, depending on the country:

- **`post_code`** (default): used by most countries. Example: `"10999"`
- **`zip_code`**: used in the United States
- **`eircode`**: used in Ireland

## Administrative Areas

The address supports up to 3 levels of administrative areas, `administrative_area_level_1` through `administrative_area_level_3`.

The following fields are used for administrative divisions, depending on the country:

- **`province`** (default): used in some countries for administrative divisions
- **`state`**: used in countries like the United States for the top-level administrative unit
- **`region`**: used in countries like Chile for administrative divisions
- **`county`**: used in countries like Ireland and Romania
- **`autonomous_community`**: used in Spain for the first sub-national level

## Locality Levels

The address supports up to 3 levels of locality levels, `locality_level_1`
through `locality_level_3`.

For more specific location information:

- **`city`** (default): a city
- **`post_town`**: used in Great Britain instead of city
- **`district`**: a district within a city or region
- **`neighborhood`**: a neighborhood or local area
- **`suburb`**: a suburb or outlying area of a city
- **`village`**: a village or small settlement
- **`municipality`**: a municipality or local government area

## Country-Specific Requirements

Use the table below to search by country, field name, alias, and requirement.

<SearchableTable
  client:load
  searchPlaceholder="Search countries or address fields"
  columns={[
    { key: "icon", label: "" },
    { key: "country", label: "Country", nowrap: true },
    { key: "fields", label: "Fields", minWidth: "18rem" },
  ]}
  rows={[
    {
      icon: "flag_ar",
      country: "Argentina (AR)",
      fields: "street_address, post_code, city, province (Optional)",
    },
    {
      icon: "flag_au",
      country: "Australia (AU)",
      fields: "street_address, city, state, post_code",
    },
    {
      icon: "flag_at",
      country: "Austria (AT)",
      fields: "street_address, post_code, city",
    },
    {
      icon: "flag_be",
      country: "Belgium (BE)",
      fields: "street_address, post_code, city",
    },
    {
      icon: "flag_br",
      country: "Brazil (BR)",
      fields: "street_address, post_code, city, neighborhood, state",
    },
    {
      icon: "flag_bg",
      country: "Bulgaria (BG)",
      fields: "street_address, post_code, city",
    },
    {
      icon: "flag_ca",
      country: "Canada (CA)",
      fields: "street_address, city, province, post_code",
    },
    {
      icon: "flag_cl",
      country: "Chile (CL)",
      fields: "street_address, post_code, city, region, province (Optional), commune",
    },
    {
      icon: "flag_co",
      country: "Colombia (CO)",
      fields: "street_address, district (Optional), city, department, municipality, post_code (Optional)",
    },
    {
      icon: "flag_hr",
      country: "Croatia (HR)",
      fields: "street_address, post_code, city",
    },
    {
      icon: "flag_cy",
      country: "Cyprus (CY)",
      fields: "street_address, post_code, city",
    },
    {
      icon: "flag_cz",
      country: "Czech Republic (CZ)",
      fields: "street_address, post_code, city",
    },
    {
      icon: "flag_dk",
      country: "Denmark (DK)",
      fields: "street_address, post_code, city",
    },
    {
      icon: "flag_ee",
      country: "Estonia (EE)",
      fields: "street_address, post_code, city, province (Optional)",
    },
    {
      icon: "flag_fi",
      country: "Finland (FI)",
      fields: "street_address, post_code, city",
    },
    {
      icon: "flag_fr",
      country: "France (FR)",
      fields: "street_address, post_code, city",
    },
    {
      icon: "flag_de",
      country: "Germany (DE)",
      fields: "street_address, post_code, city",
    },
    {
      icon: "flag_gr",
      country: "Greece (GR)",
      fields: "street_address, post_code, city",
    },
    {
      icon: "flag_hu",
      country: "Hungary (HU)",
      fields: "city, street_address, post_code",
    },
    {
      icon: "flag_ie",
      country: "Ireland (IE)",
      fields: "street_address, townland (Optional), city, county, eircode",
    },
    {
      icon: "flag_it",
      country: "Italy (IT)",
      fields: "street_address, post_code, city, province",
    },
    {
      icon: "flag_lv",
      country: "Latvia (LV)",
      fields: "street_address, province (Optional), city, post_code",
    },
    {
      icon: "flag_lt",
      country: "Lithuania (LT)",
      fields: "street_address, post_code, city, province (Optional)",
    },
    {
      icon: "flag_lu",
      country: "Luxembourg (LU)",
      fields: "street_address, post_code, city",
    },
    {
      icon: "flag_mt",
      country: "Malta (MT)",
      fields: "street_address, city, post_code",
    },
    {
      icon: "flag_mx",
      country: "Mexico (MX)",
      fields: "street_address, post_code, city, neighborhood (Optional), state",
    },
    {
      icon: "flag_nl",
      country: "Netherlands (NL)",
      fields: "street_address, post_code, city",
    },
    {
      icon: "flag_no",
      country: "Norway (NO)",
      fields: "street_address, post_code, post_town",
    },
    {
      icon: "flag_pe",
      country: "Peru (PE)",
      fields: "street_address, city (Optional), post_code, department, province (Optional), district",
    },
    {
      icon: "flag_pl",
      country: "Poland (PL)",
      fields: "street_address, post_code, city, province (Optional)",
    },
    {
      icon: "flag_pt",
      country: "Portugal (PT)",
      fields: "street_address, post_code, city, district (Optional)",
    },
    {
      icon: "flag_ro",
      country: "Romania (RO)",
      fields: "street_address, post_code, county (Optional), city",
    },
    {
      icon: "flag_sk",
      country: "Slovakia (SK)",
      fields: "street_address, post_code, city",
    },
    {
      icon: "flag_si",
      country: "Slovenia (SI)",
      fields: "street_address, post_code, city",
    },
    {
      icon: "flag_es",
      country: "Spain (ES)",
      fields: "street_address, post_code, city, province",
    },
    {
      icon: "flag_se",
      country: "Sweden (SE)",
      fields: "street_address, post_code, post_town",
    },
    {
      icon: "flag_ch",
      country: "Switzerland (CH)",
      fields: "street_address, post_code, city",
    },
    {
      icon: "flag_gb",
      country: "United Kingdom (GB)",
      fields: "street_address, post_town, post_code",
    },
    {
      icon: "flag_us",
      country: "United States (US)",
      fields: "street_address, city, state, zip_code",
    },
  ]}
  tableLayout="auto"
/>