# Country Picker

> A searchable country-only picker with flags, aliases, native names, ISO-3 codes, and calling-code search.

A shadcn/ui block from the [@flagcn](https://flagcn.dev) registry, listed on [shadcn.exchange](https://shadcn.exchange/r/flagcn/country-picker).

- Page, with a live preview: https://shadcn.exchange/r/flagcn/country-picker
- Screenshot: https://abzjhwgwpdpz7ua5.public.blob.vercel-storage.com/shots/flagcn/country-picker-light-720d1f22e771d1e4.png
- Registry item: https://flagcn.dev/r/country-picker.json
- Categories: countries, forms, combobox
- Listed: 2026-10-13, source last changed 2026-10-13

## Install

```bash
npx shadcn@latest add https://flagcn.dev/r/country-picker.json
```

Run it in a project that has shadcn/ui set up. It adds the files below and installs what they depend on.

## Dependencies

- Registry items: `@flagcn/flag-picker`, `@flagcn/country-data`

## Notes from the registry

Use countries to constrain the list and value/onValueChange for controlled state.

## Files

### `src/components/flags/country-picker.tsx`

```tsx
// SPDX-License-Identifier: MIT

import type { ComponentProps } from "react"

import { countryData, type CountryCode } from "./data/countries"
import { FlagPicker } from "./flag-picker"

export interface CountryPickerProps extends Omit<ComponentProps<typeof FlagPicker>, "value" | "defaultValue" | "onValueChange" | "codes" | "kinds"> {
  value?: CountryCode
  defaultValue?: CountryCode
  onValueChange?: (code: CountryCode) => void
  countries?: readonly CountryCode[]
}

export function CountryPicker({ countries = countryData.map((country) => country.code), onValueChange, ...props }: CountryPickerProps) {
  return (
    <FlagPicker
      kinds={["country"]}
      codes={countries}
      placeholder="Select a country"
      searchPlaceholder="Search country, ISO, or calling code…"
      emptyMessage="No countries found."
      onValueChange={(code) => onValueChange?.(code as CountryCode)}
      {...props}
    />
  )
}
```
