# Address Autocomplete

> A Places-style address field. Typing the street loads suggestions from your own async search (debounced, stale requests aborted) with matched words in bold and a Powered by slot. Picking one opens an editable breakdown with labels that follow the country, a drawn location pin and focus on the apartment line. Manual entry is one arrow away, and every input has the right autocomplete token.

- Slug: `address-autocomplete`
- Category: [Inputs](https://www.assembli.design/category/inputs.md)
- Type: component
- Tags: address, autocomplete, places, checkout, shipping, location, combobox, base-ui
- npm dependencies: @base-ui/react, lucide-react, motion
- shadcn/ui dependencies: none
- Live preview: https://www.assembli.design/preview/address-autocomplete
- Page: https://www.assembli.design/components/address-autocomplete

![Address Autocomplete preview](https://www.assembli.design/thumbnails/address-autocomplete-light.png)

## Props

Other props pass through to the root element.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `search` (required) | `(query: string, signal: AbortSignal) => Promise<AddressSuggestion[]>` |  | Looks addresses up as the visitor types (debounced, and aborted when a newer query starts). |
| `resolve` | `(suggestion: AddressSuggestion, signal: AbortSignal) => Promise<Address>` |  | Turns a picked suggestion into a full address when suggestions don't carry one. |
| `onChange` | `(address: Address \| null, source: AddressSource \| null) => void` |  | Fires with the structured address whenever it changes, or `null` once cleared. |
| `defaultValue` | `Address` |  | Starts filled in and expanded, as if picked from a suggestion. |
| `label` | `React.ReactNode` | `"Address"` |  |
| `hint` | `React.ReactNode` |  |  |
| `description` | `React.ReactNode` |  |  |
| `error` | `React.ReactNode` |  | Replaces the description and marks the street field `aria-invalid`. |
| `placeholder` | `string` | `"Start typing your street address"` |  |
| `attribution` | `React.ReactNode` |  | Shown at the foot of the suggestions, such as "Powered by …". Most address APIs require it. |
| `countries` | `AddressCountry[]` | `COUNTRIES` | Countries in the country select. |
| `defaultCountry` | `string` | `"US"` | Country for a manual address before one is chosen. |
| `section` | `"shipping" \| "billing"` |  | Prefixes every autocomplete token, so a page can hold a shipping and a billing address. |
| `minLength` | `number` | `3` | Characters typed before suggestions load. Defaults to 3. |
| `debounce` | `number` | `200` | Delay before `search` runs, in ms. Defaults to 200. |
| `name` | `string` |  | Names every input `name.line1`, `name.city` … so the address posts with a surrounding form. |
| `required` | `boolean` |  |  |
| `disabled` | `boolean` |  |  |

## Install

One-time setup (needs a subscription):

1. Add the registry to the project's `components.json`: `{"@assembli":{"url":"https://www.assembli.design/r/{name}.json","headers":{"Authorization":"Bearer ${ASSEMBLI_API_KEY}"}}}` (merge into `"registries"`).
2. Put an API key from https://www.assembli.design/account in `.env.local` as `ASSEMBLI_API_KEY=asm_…`.

Then install with the shadcn CLI (writes `components/address-autocomplete/address-autocomplete.tsx` and installs dependencies):

```bash
npx shadcn@latest add @assembli/address-autocomplete
```

Registry item JSON: https://www.assembli.design/r/address-autocomplete.json (send `Authorization: Bearer <api key>`)

## Code

> Component source needs an Assembli subscription ($12/month or $96/year) and an API key sent as `Authorization: Bearer <key>`. To get one without copying anything, POST https://www.assembli.design/api/agent/login (or call the MCP tool connect_account), show the user the link it returns, and poll https://www.assembli.design/api/agent/token for the key. Or subscribe at https://www.assembli.design/pricing and create a key at https://www.assembli.design/account.
