Pro unlocks unlimited templates48:00:00Get Pro →

Country & City Selector

Popovers with in-panel search (same pattern as Phone Input). Compose country, optional state, and optional city. Data loads on demand — light state shards first; city shards only when a city field needs them.

Country + state + city

Full cascade. States load a light shard; cities wait until a state is chosen.

Loading…

Installation

CLI
npx @sonojs/ui@latest add country-city-selector
Also needs
npx @sonojs/ui@latest add input-group popover
npm i @sonojs/geo lucide-react

Usage

country-city-selector
import { CountryCitySelect } from "@/components/country-city-selector"

export function Example() {
  return (
    <>
      <CountryCitySelect includeState includeCity showFlags />
      <CountryCitySelect includeState includeCity={false} showFlags />
      <CountryCitySelect includeCity={false} showFlags />
    </>
  )
}

CountrySearchSelect

Exported for custom layouts. Docs examples use CountryCitySelect only.

PropTypeDefaultDescription
valuestring · null-Controlled ISO-3166 alpha-2 (CountrySearchSelect only).
showFlagsboolean-Flags in the country popover list.
geoDataBaseUrlstring-Geo data base URL (jsDelivr default).

CountryCitySelect

PropTypeDefaultDescription
includeStateboolean-Show state/province after country.
includeCityboolean-Show city. With `includeState`, city waits for a state.
country / defaultCountrystring · null-ISO-3166 alpha-2.
stateId / defaultStateIdnumber · null-State id when `includeState` is true.
cityId / defaultCityIdnumber · null-City id when `includeCity` is true.
onCountryChange / onStateChange / onCityChangecallbacks-Downstream values clear when a parent field changes.
showFlagsboolean-Country flags in the country popover.
geoDataBaseUrlstring-Shard base for all fields.
disabledboolean-Disable all controls.