Skip to main content

API Reference

Component Props

PropTypeDefaultDescription
fetchSuggestions(query: string) => Promise<LocationSuggestion[]>undefinedCustom fetch function for retrieving location suggestions. Required when not using a built-in provider
providerLocationProviderundefinedBuilt-in provider name ('openstreetmap', 'mapbox', 'google', etc.)
providerConfigProviderConfig{}Provider configuration including API keys and base URLs
queryOptionsQueryOptions{}Provider-specific query parameters
onLocationSelect(location: LocationSuggestion) => voidundefinedCallback when a location is selected
onQueryChange(query: string) => voidundefinedCallback when search query changes
placeholderstring"Search for a location..."Input placeholder text
debounceMsnumber300Debounce delay for API calls in milliseconds
showRecentSearchesbooleantrueShow recent searches when input is empty
recentSearchesstring[][]Array of recent search terms
onRecentSearchesChange(searches: string[]) => voidundefinedCallback when recent searches update
maxRecentSearchesnumber5Maximum number of recent searches to keep
themeDeepPartial<LocationAutocompleteTheme>{}Custom theme configuration
attributionReact.ComponentType | React.ReactElementnullAttribution component for provider

Style Props

PropTypeDescription
containerStyleViewStyleStyle for the main wrapper container
inputContainerStyleViewStyleStyle for the input container (with search icon, input, clear button)
inputStyleTextStyleStyle for the TextInput field itself
suggestionStyleViewStyleStyle for individual suggestion items
textStyleTextStyleStyle for text elements (titles, labels)
autocompleteContainerStyleViewStyleStyle for the autocomplete suggestions container
autocompleteSuggestionItemStyleViewStyleStyle for individual autocomplete suggestion items
autocompleteSuggestionTextStyleTextStyleStyle for suggestion text

Type Definitions

LocationSuggestion

interface LocationSuggestion<Raw = unknown> {
place_id: string;
display_name: string;
lat: string;
lon: string;
type: string;
importance: number;
raw?: Raw;
}

LocationProvider

type LocationProvider =
| 'openstreetmap'
| 'mapbox'
| 'google'
| 'geoapify'
| 'locationiq'
| 'here'
| 'tomtom'
| 'opencage';

ProviderConfig

interface ProviderConfig {
apiKey?: string;
baseUrl?: string;
}

QueryOptions

interface QueryOptions {
[key: string]: string | number | boolean;
}

Provider Options

Each provider can be configured with specific options:

Common Options

OptionTypeDescription
apiKeystringAPI key for the provider
baseUrlstringCustom base URL (optional)

Provider-Specific Options

Google Places

{
apiKey: string;
language?: string;
region?: string;
sessionToken?: string;
}

Mapbox

{
apiKey: string;
country?: string;
proximity?: [number, number]; // [longitude, latitude]
language?: string;
}

OpenStreetMap (Nominatim)

{
userAgent: string; // Required for production use
email?: string; // Required for high-volume usage
language?: string;
}

Theme Interface

interface LocationAutocompleteTheme {
colors: {
background: string;
surface: string;
primary: string;
onSurface: string;
onSurfaceVariant: string;
outline: string;
error: string;
onError: string;
shadow: string;
};
spacing: {
xs: number;
sm: number;
md: number;
lg: number;
xl: number;
iconMargin: number;
iconPadding: number;
loaderMargin: number;
};
borderRadius: {
sm: number;
md: number;
lg: number;
};
typography: {
body: {
fontSize: number;
fontWeight: FontWeight;
};
bodySmall: {
fontSize: number;
fontWeight: FontWeight;
};
titleMedium: {
fontSize: number;
fontWeight: FontWeight;
};
};
icons: {
search: {
size: number;
color?: string;
};
mapPin: {
size: number;
color?: string;
};
clock: {
size: number;
color?: string;
};
clear: {
size: number;
color?: string;
};
};
}