# Country Select

> A searchable country picker: flag, name and dial code on every row, a Suggested group on top and the picked flag in the trigger. Search by name, ISO code or dial code. Also exports PhonePrefixSelect, a compact flag and dial-code trigger for phone numbers, and PhoneInput, which attaches it to a phone field in the same shell as text-field.

- Slug: `country-select`
- Category: [Selects](https://www.assembli.design/category/selects.md)
- Type: component
- Tags: country, select, combobox, phone, flag, address
- npm dependencies: @base-ui/react, lucide-react
- shadcn/ui dependencies: none
- Live preview: https://www.assembli.design/preview/country-select
- Page: https://www.assembli.design/components/country-select

![Country Select preview](https://www.assembli.design/thumbnails/country-select-light.png)

## Props

Other props pass through to the root element.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `value` | `string \| null` |  | An ISO 3166-1 alpha-2 code, such as `"GB"`. |
| `defaultValue` | `string \| null` |  |  |
| `onValueChange` | `(code: string \| null, country: Country \| null) => void` |  |  |
| `suggested` | `string[]` |  | Codes listed under "Suggested" while the search is empty. |
| `countries` | `Country[]` |  | Replace the built-in list. |
| `size` | `SelectSize` | `"md"` |  |
| `disabled` | `boolean` |  |  |
| `required` | `boolean` |  |  |
| `name` | `string` |  | Submits the ISO code with a surrounding form. |
| `open` | `boolean` |  |  |
| `defaultOpen` | `boolean` |  |  |
| `onOpenChange` | `(open: boolean) => void` |  |  |
| `label` | `React.ReactNode` |  |  |
| `hint` | `React.ReactNode` |  | Quiet text to the right of the label, such as "Optional". |
| `description` | `React.ReactNode` |  |  |
| `error` | `React.ReactNode` |  | Replaces the description and marks the trigger `aria-invalid`. |
| `placeholder` | `React.ReactNode` | `"Select a country"` |  |
| `showDialCode` | `boolean` | `true` | Shows each country's dial code in the list. Defaults to `true`. |
| `triggerClassName` | `string` |  | Classes for the trigger; `className` goes on the root. |

## Install

One-time setup (needs a subscription):

1. Add the registry to the project's `components.json`: `{"@assembli":{"url":"https://www.assembli.design/r/{name}.json","headers":{"Authorization":"Bearer ${ASSEMBLI_API_KEY}"}}}` (merge into `"registries"`).
2. Put an API key from https://www.assembli.design/account in `.env.local` as `ASSEMBLI_API_KEY=asm_…`.

Then install with the shadcn CLI (writes `components/country-select/country-select.tsx` and installs dependencies):

```bash
npx shadcn@latest add @assembli/country-select
```

Registry item JSON: https://www.assembli.design/r/country-select.json (send `Authorization: Bearer <api key>`)

## Code

> Component source needs an Assembli subscription ($12/month or $96/year) and an API key sent as `Authorization: Bearer <key>`. To get one without copying anything, POST https://www.assembli.design/api/agent/login (or call the MCP tool connect_account), show the user the link it returns, and poll https://www.assembli.design/api/agent/token for the key. Or subscribe at https://www.assembli.design/pricing and create a key at https://www.assembli.design/account.
