dentil

Country Select

CountrySelect is a Select Search over every ISO 3166-1 country. Names come from Intl.DisplayNames, so pass locale to translate and sort them. Pass preferredCountries to list those codes first, and showFlags for a flag beside each country. The first select does both, for GB and US. The second is limited to six countries and named in German. Search by name or by code.

@dentil/country-select
On this page
Result: —
Result: —

Installation

pnpm dlx shadcn@latest add @dentil/country-select
npx shadcn@latest add @dentil/country-select
yarn dlx shadcn@latest add @dentil/country-select
bunx --bun shadcn@latest add @dentil/country-select

Files land in components/dentil/country-select/. It installs @dentil/select-search and country-flag-icons. Country names come from Intl.DisplayNames, not a data file.

API reference

CountrySelect

PropTypeDefaultDescription
valuestring | null | undefined—ISO 3166-1 alpha-2 code, e.g. GB.
onChange(value: string) => void—Called with the picked code.
allowedCountriesstring[]—Only list these codes. Lists all 250 when omitted.
preferredCountriesstring[]—ISO codes listed first, in this order. A separator sits under them until the search field has text. Unknown codes are ignored.
showFlagsbooleanfalseDraws a flag beside each country, in the list and on the trigger. Same icons as Phone Input.
localestring'en'Locale for country names and sort order, from Intl.DisplayNames.
…propsSelectSearchProps—Any SelectSearch prop except options, such as placeholder and emptyText.