Pro unlocks unlimited templates48:00:00Get Pro →

Address Autocomplete

Type to search addresses. Works out of the box with a bundled offline mock — override onSearch with Mapbox Search (or any geocoder) in production.

Gallery

Search, select, and clear. Pass any async onSearch — demos use the bundled mock.

Loading…

Installation

CLI
npx @sonojs/ui@latest add address-autocomplete
Also needs
npx @sonojs/ui@latest add command input-group
npm i lucide-react

Usage

address-autocomplete.tsx
import { AddressAutocomplete } from "@/components/address-autocomplete"

export function Example() {
  return (
    <AddressAutocomplete
      placeholder="Try “new” or “london”…"
      onValueChange={(address) => {
        console.log(address)
      }}
    />
  )
}

Props

PropTypeDefaultDescription
onSearch(query: string) => Promise<AddressSuggestion[]>searchMockAddressesAsync lookup. Defaults to the bundled mock; replace with your geocoder in production. Stale responses are ignored.
valueAddressValue · null-Controlled selected address.
defaultValueAddressValue · nullnullInitial address when uncontrolled.
onValueChange(value: AddressValue · null) => void-Fires on select or clear.
debounceMsnumber300Delay before calling `onSearch`.
minCharsnumber2Minimum query length before searching.
placeholderstring"Search address…"Input placeholder when empty.
emptyMessagestring"No addresses found."Shown when `onSearch` returns an empty list.
loadingMessagestring"Searching…"Shown while `onSearch` is pending.
errorMessagestring"Could not load addresses."Shown when `onSearch` throws.
disabledbooleanfalseDisables the field.
invalidbooleanfalseDestructive border via `aria-invalid`.
classNamestring-Merged onto the `InputGroup` root.

Related