A searchable combobox for picking a country or region, with a flag-and-name trigger and a keyboard-navigable list of every ISO region. Open it and type to filter by name or code, then arrow down and press Enter to choose.
The region selector is a searchable combobox for picking a country or region. A trigger pill shows the current selection as a circular flag plus its name; opening it reveals an anchored popover with a search field and a keyboard-navigable list of every region. It ships with the full ISO 3166-1 set of 245 regions out of the box.
Type to filter by name or two-letter code, arrow through the results, and press Enter to choose. Use it anywhere a form needs a country or region field: billing, shipping, account settings, or onboarding.
Import the pattern from loosethreads:
import { RegionSelector } from "@pulp/loosethreads/patterns"Hold the selected code in state and pass it as value, then update it from onChange. The value is the region's lowercase ISO alpha-2 code, e.g. "us":
import { RegionSelector } from "@pulp/loosethreads/patterns"
import { useState } from "react"
function RegionField() {
const [region, setRegion] = useState("us")
return (
<RegionSelector
value={region}
onChange={setRegion}
placeholder="Search by country or region"
/>
)
}| Prop | Type | Default | Description |
|---|---|---|---|
regions | Array<{ code: string; name: string }> | built-in 245-region set | The list of selectable regions. Each entry is a lowercase ISO 3166-1 alpha-2 code and a display name. Defaults to the bundled alphabetical set of 245 regions. |
value | string | undefined | Controlled selection, as a region code. Provide it alongside onChange to drive the picker from your own state. |
defaultValue | string | "us" | Initial selection when uncontrolled. Ignored when value is set. |
onChange | (code: string) => void | undefined | Called with the chosen region's code when the user makes a selection. The popover closes and the search field resets afterward. |
placeholder | string | "Search by country or region" | Placeholder text for the search field inside the popover. |
searchable | boolean | true | Whether the search field is shown. When enabled, results filter as you type by region name or code. |
The control has two parts. The trigger is a pill holding the selected flag, the region name, and a chevron that rotates when the popover opens. The popover, anchored directly beneath the trigger, stacks a search field over a scrollable list; each row shows a flag and name, and the current selection is marked with an iris-magenta label and a check.
Flags load lazily from a remote source. Each flag is a plain lazily-loaded img from flagcdn.com, so first paint does not wait on the full set. Make sure your content policy allows that origin, or swap in your own flag assets.
role="combobox" with aria-haspopup="listbox", an aria-expanded that tracks the open state, and an aria-label that announces the current selection.role="listbox"; each row is a role="option" and the chosen region carries aria-selected. The search field is labelled and wired to the list with aria-controls.aria-selected and reinforced visually with an iris-magenta name and a check mark.Next: Scroll-stack cards. Back to Controls & inputs.