Skip to Content

City Selector

A dropdown for selecting cities, filtered based on the selected country and state. The final component in the cascading location selector trio.


Import

import { CitySelector } from "@phpcreation/frontend-components-react-nextjs-bundle/components/CitySelector";

Props

PropTypeDefaultDescription
countrystring""ISO country code
statestring""State code
valuestring""Controlled city value
onChange(city: string) => voidChange handler
placeholderstring"Select city..."Placeholder text
disabledbooleanfalseDisable the control
classNamestringAdditional CSS classes

Usage

import { CountrySelector } from "..."; import { StateSelector } from "..."; import { CitySelector } from "..."; const [country, setCountry] = useState("US"); const [state, setState] = useState("CA"); const [city, setCity] = useState(""); <CountrySelector value={country} onChange={setCountry} /> <StateSelector country={country} value={state} onChange={setState} /> <CitySelector country={country} state={state} value={city} onChange={setCity} />

Last updated on