vue3-country-select
A Vue 3 component for country selection with TypeScript support
1,304
| Install | |
|---|---|
npm install vue3-country-select |
|
| Latest Version: | 1.0.1 |
| Vue: | 3 |
| License: | MIT |
| Last Updated: | Nov 10, 2024 |
| Links: | GitHub · npm |
Maintainer: jaimecalderon19
Vue 3 Country Select
A Vue 3 component for country selection with TypeScript support. This component allows you to easily add a country selector to your Vue 3 applications with full TypeScript support.
Features
- 🚀 Built for Vue 3
- 📘 Full TypeScript support
- 🎨 Customizable styling
- 🌍 All countries included
- 🔍 Search functionality
- ⭐ Preferred countries option
- 📱 Mobile friendly
- 🔄 Auto-detection of user's country
Preview

Installation
npm install vue3-country-select
Basic Usage
<script setup lang="ts">
import { ref } from 'vue'
import { VueCountryCode } from 'vue3-country-select'
import "vue3-country-select/style.css"
interface Country {
iso2: string
name: string
dialCode: string
preferred?: boolean
}
const selectedCountry = ref<Country | null>(null)
const onSelect = (data: Country) => {
selectedCountry.value = data
}
</script>
<template>
<VueCountryCode
@onSelect="onSelect"
:preferredCountries="['vn', 'us', 'gb']"
/>
</template>
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| preferredCountries | string[] | [] | Array of country codes (ISO 2) to show at the top of the list |
| disabled | boolean | false | Disable the component |
| placeholder | string | "Select Country" | Placeholder text |
| searchPlaceholder | string | "Search" | Search input placeholder |
Events
| Event | Parameters | Description |
|---|---|---|
| onSelect | Country | Emitted when a country is selected |
Types
interface Country {
iso2: string
name: string
dialCode: string
preferred?: boolean
}
Styling
The component comes with default styling that you can import:
import "vue3-country-select/style.css"
Auto-detection
The component includes built-in country auto-detection functionality. It will attempt to detect the user's country based on their IP address using a reliable geolocation service.
Credits
This package is inspired by vue-country-code-select but built specifically for Vue 3 with TypeScript support.
Related Packages
@timbouc/vuetify-country-region-input
A Vuetify country and region input select component with vue-i18n support. Use c...
3,076
3
vuetify-country-search
This package provides a pair of Vuetify components for countries/region select i...
2,190
6
Version History
| Version | Released | Vue | License |
|---|---|---|---|
| 1.0.1 | ^3.0.0 | MIT | |
| 1.0.0 | ^3.0.0 | MIT |