vue-country-code-select

Country Code Select with Vue
26,168 8
Install
npm install vue-country-code-select
Latest Version:1.6.7
Vue:2
License:MIT
Last Updated:Jul 30, 2021
Links: GitHub  ·  npm
Maintainer: denfedweb

vue-country-code-select

Country Code Select with Vue.

Checkout Demo at Github pages.

Installation

  • yarn:
      yarn add vue-country-code-select
    
  • npm:
      npm i --save vue-country-code-select
    

Usage

  • Install as a global component:

    import Vue from "vue";
    import VueCountryCode from "vue-country-code-select";
    
    Vue.use(VueCountryCode);
    
  • In your component:

    <template>
    ...
       <vue-country-code
                      @onSelect="onSelect"
                      <!-- optional -->
                      :preferredCountries="['vn', 'us', 'gb']">
       </vue-country-code>
    ...
    <template>
    <script>
    export default {
      data() {
        return {
        };
      },
      methods: {
         onSelect({name, iso2, dialCode}) {
           console.log(name, iso2, dialCode);
         },
      },
    }
    </script>
    
  • Register the new field as a global component

Props

Property value Type Default value Description
defaultCountry string '' Default country, will override the country fetched from IP address of user
searchPlaceholderText string '' Default text - "Search country"
enableSearchField Boolean '' Default "false"
disabledFetchingCountry Boolean false Disable fetching current country based on IP address of user
enabledCountryCode Boolean false Enable country code in the input
enabledFlags Boolean true Enable flags in the input
preferredCountries Array [] Preferred countries list, will be on top of the dropdown. ie ['AU', 'BR']
onlyCountries Array [] List of countries will be shown on the dropdown. ie ['AU', 'BR']
ignoredCountries Array [] List of countries will NOT be shown on the dropdown. ie ['AU', 'BR']
dropdownOptions Object { disabledDialCode: false } Options for dropdown, supporting disabledDialCode

Events

Property value Arguments Description
onSelect Object Fires when the input changes with the argument is the object includes { name, iso2, dialCode }

Highlights & Credits

Demo Usage


# install dependencies
$ yarn/npm install

# compile demo and start serve for development
$ yarn/npm dev

# build
$ yarn/npm build

Made by Mon.

Related Packages

@kingscode/vuetify-phone-input

A Vuetify form control usable for phone numbers. Supports country code, auto for...

11,175
vue-simple-phone

A multilingual, simple, and extendable phone number input component for Vue

6,964 4
vue-tel-mini-input

International Telephone Input with Vue

1,883 0

Version History

Version Released Vue License
1.6.7 ^2.6.11 MIT
1.5.7 ^2.6.11 MIT
1.5.6 ^2.6.11 MIT
1.5.5 ^2.6.11 MIT
1.5.1 ^2.6.11 MIT