Store Locator
ProNewSearch, filters and a store list with distance, live opening hours and directions beside the map. On phones the list and the map take turns.
Installation
First time? Add the @viewport registry to components.json. Setup takes one minute.
Usage
Props
| Prop | Type | Default |
|---|---|---|
| stores* | Store[] | — |
| title | string | "Find a store" |
| origin | LatLngThe visitor's position. Distances are measured from it and the list is sorted nearest first. | — |
| units | "mi" | "km" | "mi" |
| onLocate | () => voidShows a "Use my location" button. Look the position up yourself and pass it back as `origin`. | — |
| locating | booleanSpinner on the location button while you wait for a position. | — |
| onSearch | (query: string) => voidCalled when the search is submitted, for geocoding on your side. The list always filters as you type. | — |
| searchPlaceholder | string | "City, ZIP or store name" |
| filterable | booleanThe Filters button and panel, built from every store's category and tags. | true |
| listPosition | "left" | "right"Which side the list sits on when there is room for both. | "left" |
| defaultView | "list" | "map"What phones show first. | "list" |
| thumbnails | booleanRow photos. | true |
| selectedId | string | nullThe open store, for controlled use. | — |
| defaultSelectedId | string | — |
| onSelect | (id: string | null) => void | — |
| now | DateThe moment used for "Open now". Defaults to the visitor's clock, refreshed every minute. | — |
| timeFormat | "12h" | "24h" | "12h" |
| accent | stringButtons, pins and highlights. Defaults to the theme's foreground. | "var(--foreground)" |
| accentForeground | string | "var(--background)" |
| mapStyle | MapStyle | "auto" |
| markerStyle | MarkerStyle | "pin" |
| tiles | stringA raster tile URL with `{z}`, `{x}` and `{y}`. Leave it out for the built-in street surface. | — |
| attribution | React.ReactNode | — |
| renderSurface | (context: MapSurfaceContext) => React.ReactNodeDraw the map surface yourself. | — |
| getDirectionsUrl | (store: Store) => stringWhere Directions goes. Defaults to a Google Maps directions link. | directionsUrl |
| height | number | stringHeight in pixels, or any CSS length. | 640 |
| loading | boolean | — |
| error | stringAn error message in place of the list, with a retry button when `onRetry` is set. | — |
| onRetry | () => void | — |
| className | string | — |
Accessibility
- Search is a real search form; a status line announces how many locations match as you type or filter.
- Filters are toggle buttons that report their pressed state; the results button has its own accessible name and a separate live count.
- Opening a store moves focus into its details; Escape or Close puts it back on the row or marker you came from.
- Supplied websites only link when they resolve to HTTP(S); unsafe schemes remain text.
- The weekly hours are a table with today marked. Under 720px one floating button swaps list and map, and the hidden one is inert.