Hey everyone! I'm super excited to introduce ng-country-select β a high-performance, multilingual country autocomplete built on Angular and Angular Material. If youβve ever needed a quick and elegant way to select countries in your apps (complete with flags, codes, and translations), look no further!
β¨ Why ng-country-select?
- π Angular 16+ Ready β Fully compatible with Angular 16, 17, 18, and 19.
- π Multi-Language Magic β English, German, French, Spanish and Italian out of the box, and super easy to add more.
- π Automatic Flag Emojis β Zero image dependencies! Relying on ISO codes for the magic.
- π Intelligent Search β Match by local name, English name, alpha2/3 codes, or any available translation.
- π¨ Material Design β Seamless integration with Angular Material for a polished UI.
- β‘ Performance β RxJS-based searching with debouncing and optional virtual scrolling.
- 𧩠Standalone β Import the component directly, no extra boilerplate needed.
πΊ Live Demo
Try it out in our Live Demo and see it in action!
π Angular Compatibility
Angular Version | Supported? |
---|---|
β Yes | |
β Yes | |
β Yes | |
β Yes |
π οΈ Setup in 60 Seconds
1. Install Dependencies
npm install --save @angular/material @angular/cdk @angular/animations @wlucha/ng-country-select
2. Import Component
import { CountrySelectComponent } from '@wlucha/ng-country-select';
@NgModule({
imports: [
CountrySelectComponent,
// ... other imports
]
})
3. Add Basic Usage
<ng-country-select
[lang]="'en'"
(countrySelected)="handleSelection($event)"
></ng-country-select>
ποΈ Parameters
ποΈ Inputs
Parameter | Type | Default | Description |
---|---|---|---|
defaultCountry |
`Country \ | null` | null |
selectedCountry |
`Country \ | null` | - |
lang |
string |
'en' |
Language for displaying country names (e.g., en , de , fr ) |
searchAllLanguages |
boolean |
false |
If true , searching will match in all available translations |
placeholder |
string |
'Search country' |
Placeholder text for the input field |
debounceTime |
number |
100 |
Debounce time in milliseconds for the search input |
disabled |
boolean |
false |
Disables the component if true
|
appearance |
`'fill' \ | 'outline'` | 'fill' |
required |
boolean |
false |
Marks the field as required if true
|
showCodes |
boolean |
false |
If true , shows alpha2/alpha3 codes in the autocomplete results |
color |
ThemePalette |
'primary' |
Angular Material color palette to use ('primary' , 'accent' , 'warn' ) |
π¨ Outputs
Event | Output | Description |
---|---|---|
countrySelected |
Country |
Full country object on selection |
inputChanged |
string |
Live search term updates |
closed |
void |
When dropdown closes |
π» Power User Setup
<ng-country-select
[lang]="'en'"
[searchAllLanguages]="true"
[showCodes]="true"
[debounceTime]="200"
[appearance]="'outline'"
[placeholder]="'Search country'"
(countrySelected)="onCountrySelect($event)"
(inputChanged)="trackSearchTerm($event)"
></ng-country-select>
π Support the Project
Love this component? Here's how you can help:
- β Star the repo (you're awesome!)
- π Report bugs here
- π‘ Suggest features
- π’ Share with your network
# Your star fuels development! β
# Clone and explore:
git clone https://github.com/wlucha/ng-country-select.git
Top comments (0)