Skip to main content

CitySelector

Implemented

Multi-select city facet (SEARCH-05, ADR-055). All-cities chip clears the selection, toggling the last city off returns to All, and the selection is capped (default 5) with unselected chips disabled at the cap. Router-agnostic and i18n-free: the consumer injects copy, cookie persistence and URL updates. Handles loading, empty and error+retry states.

Categorymolecules
Sourcecomponents/molecules/CitySelector/CitySelector.tsx

Catalog fallback

Live MDX preview not available for CitySelector. Showing component catalog metadata instead.

Props

Preview

CitySelector

Prop
Type
Required
Default
Description
cities
CityOption[]
Required
—

Ordered cities ({ slug, label, count? }).

selected
string[]
Required
—

Selected slugs; empty means all cities.

onChange
(slugs: string[]) => void
Required
—

Next selection, de-duplicated and capped at max.

allLabel
string
Required
—

Label of the clearing All-cities chip.

ariaLabel
string
Optional
"Filter by city"

Accessible name of the chip group.

max
number
Optional
5

Maximum simultaneous cities.

loading
boolean
Optional
false

Renders the loading status instead of chips.

error
string | null
Optional
null

Renders a role=alert state, with retry when onRetry is provided.

onRetry
() => void
Optional
—

Retry action shown with the error state.

loadingLabel
string
Optional
"Loading cities…"

Loading copy.

errorLabel
string
Optional
"Cities are unavailable"

Fallback error copy when error is an empty string.

retryLabel
string
Optional
"Retry"

Retry button copy.

emptyLabel
string
Optional
"No cities available"

Copy when the facet is empty.

limitLabel
string
Optional
—

Status copy announced at the selection cap.

size
"sm" | "md"
Optional
"sm"

Chip size token.

className
string
Optional
—

Utility class passthrough.

Quick use:<CitySelector />

Accessibility

ARIA rolegroup

ARIA

1 rule

WAI-ARIA group/button/alert patterns

role="group" with aria-label; chips are buttons with aria-pressed; loading/empty are role=status; error is role=alert

behaviour

1 rule

ADR-055

multi-select toggles independently, All clears, last toggle-off returns to All, max caps the selection

a11y

1 rule

WCAG 2.5.5

44px tap targets via the Chip atom

Design System v4.1.0 | ePassLive