Fully controlled API
Works with v-model, [(ngModel)],
formControl, and onChange.
Open source country selector
The same country selector for Angular, React, and Vue. Supports
v-model, ngModel, and onChange.
Quick install
Angular
pnpm add @drobinetm/angular-countries-flags React
pnpm add @drobinetm/react-countries-flags Vue
pnpm add @drobinetm/vue-countries-flags
Also requires flag-icons as peer dependency.
Why use it
Works with v-model, [(ngModel)],
formControl, and onChange.
Includes keyboard support, ARIA listbox roles,
aria-selected, aria-expanded, and focus handling.
Includes ISO 3166-1 alpha-2 countries from country-list
and flag-icons. Filter the list or limit the count.
Full type exports: Country, CountriesFlagsProps,
CountryChangeEvent. Shared from @drobinetm/countries-flags-core.
Override visual tokens with CSS variables like
--drm-cf-bg, --drm-cf-radius, and
--drm-cf-focus.
@drobinetm/countries-flags-core provides the shared
data, types, and utilities used by all three implementations.
Implementations
Standalone component with ControlValueAccessor.
Works with template-driven and reactive forms.
<drm-countries-flags
[(ngModel)]="code"
[filter]="['es','us']"
/>
Controlled component with onChange,
forwardRef, and typed props.
<CountriesFlags
value={code}
onChange={(e) => setCode(e.code)}
filter={['es','us']}
/>
Vue 3 component with <script setup>,
v-model, and a @change event.
<CountriesFlags
v-model="code"
:filter="['es','us']"
@change="onSelect"
/> API Reference
| Prop / Input | Type | Default | Description |
|---|---|---|---|
max | number | 0 | Max countries shown. 0 = unlimited. |
filter | string[] | [] | ISO alpha-2 code whitelist. Empty = show all. |
value / ngModel / v-model | string | null | null | Currently selected country code (controlled). |
placeholder | string | "Select a country" | Trigger text when no country is selected. |
disabled | boolean | false | Disables user interaction. |
onChange / (valueChange) / @change | CountryChangeEvent | — | Emits { country, code } on selection. |
Theming
Use CSS variables to adjust the default look. You can override them on the host element or globally.
CSS variables
drm-countries-flags, .drm-cf {
--drm-cf-bg: rgba(10, 18, 34, 0.76);
--drm-cf-border: rgba(255,255,255, 0.08);
--drm-cf-border-hover: rgba(115,190,255, 0.24);
--drm-cf-focus: #0f6dff;
--drm-cf-radius: 14px;
--drm-cf-text: #f7f9ff;
--drm-cf-placeholder: rgba(196,209,236, 0.56);
--drm-cf-dropdown-bg: rgba(7,14,28, 0.96);
--drm-cf-accent: #8ad9ff;
}