Skip to content
ProLifetime access for $199, paid once, every future release included
Truffle UI

Store Locator

ProNew

Search, 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

pnpm dlx shadcn@latest add @viewport/store-locator

First time? Add the @viewport registry to components.json. Setup takes one minute.

Usage

The code behind the preview above comes with Truffle Pro.

Props

PropTypeDefault
stores*Store[]—
titlestring"Find a store"
originLatLng

The visitor's position. Distances are measured from it and the list is sorted nearest first.

—
units"mi" | "km""mi"
onLocate() => void

Shows a "Use my location" button. Look the position up yourself and pass it back as `origin`.

—
locatingboolean

Spinner on the location button while you wait for a position.

—
onSearch(query: string) => void

Called when the search is submitted, for geocoding on your side. The list always filters as you type.

—
searchPlaceholderstring"City, ZIP or store name"
filterableboolean

The 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"
thumbnailsboolean

Row photos.

true
selectedIdstring | null

The open store, for controlled use.

—
defaultSelectedIdstring—
onSelect(id: string | null) => void—
nowDate

The moment used for "Open now". Defaults to the visitor's clock, refreshed every minute.

—
timeFormat"12h" | "24h""12h"
accentstring

Buttons, pins and highlights. Defaults to the theme's foreground.

"var(--foreground)"
accentForegroundstring"var(--background)"
mapStyleMapStyle"auto"
markerStyleMarkerStyle"pin"
tilesstring

A raster tile URL with `{z}`, `{x}` and `{y}`. Leave it out for the built-in street surface.

—
attributionReact.ReactNode—
renderSurface(context: MapSurfaceContext) => React.ReactNode

Draw the map surface yourself.

—
getDirectionsUrl(store: Store) => string

Where Directions goes. Defaults to a Google Maps directions link.

directionsUrl
heightnumber | string

Height in pixels, or any CSS length.

640
loadingboolean—
errorstring

An error message in place of the list, with a retry button when `onRetry` is set.

—
onRetry() => void—
classNamestring—

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.