@drobinetm/vue-countries-flags
v1.0.4
Published
Vue 3 Composition API component to display a country selector with flag icons
Downloads
473
Maintainers
Readme
@drobinetm/vue-countries-flags
@drobinetm/vue-countries-flags provides a country selector component with
flag icons for Vue 3 applications.
It shares data and contracts with the Angular and React packages through
@drobinetm/countries-flags-core.
Install
Install the package and required peer dependencies.
pnpm add @drobinetm/vue-countries-flags vue flag-iconsImport the flag-icons CSS once in your app entry point.
import 'flag-icons/css/flag-icons.min.css'Basic usage
<script setup lang="ts">
import { ref } from 'vue'
import { CountriesFlags } from '@drobinetm/vue-countries-flags'
const country = ref<string | null>(null)
</script>
<template>
<CountriesFlags
v-model="country"
placeholder="Select a country"
@change="(event) => console.log(event.code)"
/>
</template>Props
CountriesFlags accepts:
modelValue?: string | nullmax?: numberfilter?: string[]placeholder?: stringdisabled?: booleanunstyled?: booleanclassNames?: CountriesFlagsClassNamesstyles?: CountriesFlagsStyles
Events
update:modelValuewithstring | nullchangewithCountryChangeEvent
Styling
By default, the package includes its own styles.
- Set
unstyledtotrueif you want to style every slot yourself. - Use
classNamesfor class-based overrides per slot. - Use
stylesfor inline style-object overrides per slot.
Available slots:
roottriggertriggerContentplaceholderlabelchevronbackdroplistemptyoptionoptionSelectedoptionActiveflagoptionName
Accessibility
The component includes keyboard and ARIA support:
Enter/Space: open or selectArrowUp/ArrowDown: move active optionHome/End: jump to first or last optionEscape: close dropdown
Exports
import {
CountriesFlags,
type Country,
type CountriesFlagsProps,
type CountryChangeEvent,
type CountriesFlagsClassNames,
type CountriesFlagsStyles,
} from '@drobinetm/vue-countries-flags'Docs
Project docs:
- https://drm-countries-flags.netlify.app/docs/vue/
License
MIT © Diovi Robinet Morales
