Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue-tel-input

Package Overview
Dependencies
Maintainers
1
Versions
146
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-tel-input

International Telephone Input with Vue

  • 2.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
108K
increased by3.81%
Maintainers
1
Weekly downloads
 
Created
Source

vue-tel-input

International Telephone Input with Vue.

Checkout Demo or Playground.

In-action GIF

Installation

  • yarn:
      yarn add vue-tel-input
    
  • npm:
      npm i --save vue-tel-input
    

Usage

  • Import default CSS to your project:

    import 'vue-tel-input/dist/vue-tel-input.css';
    
  • In your component:

    <template>
    ...
       <vue-tel-input v-model="phone"></vue-tel-input>
    ...
    <template>
    <script>
    import VueTelInput from 'vue-tel-input';
    
    export default {
      components: {
        VueTelInput,
      },
      data() {
        return {
          phone: '',
        };
      },
    }
    </script>
    

Use as a custom field of vue-form-generator

  • Add a component with vue-form-generator's abstractField

    // tel-input.vue
    <template>
      <vue-tel-input v-model="value"></vue-tel-input>
    </template>
    
    <script>
    import VueTelInput from 'vue-tel-input'
    import { abstractField } from 'vue-form-generator';
    
    export default {
      name: 'TelephoneInput',
      mixins: [abstractField],
      components: {
        VueTelInput,
      },
    };
    </script>
    
  • Register the new field as a global component

      import Vue from 'vue';
      import TelInput from '<path>/tel-input.vue';
    
      import 'vue-tel-input/dist/vue-tel-input.css';
    
      Vue.component('field-tel-input', TelInput);
    
  • Now it can be used as tel-input in schema of vue-form-generator

    var schema: {
      fields: [{
          type: "tel-input",
          label: "Awesome (tel input)",
          model: "telephone"
      }]
    };
    

Read more on vue-form-generator's instruction page

Props

Test all props on CodeSandbox.

Property valueTypeDefault valueDescription
defaultCountrystring''Default country, will override the country fetched from IP address of user
disabledFetchingCountryBooleanfalseDisable fetching current country based on IP address of user
disabledBooleanfalseDisable input field
disabledFormattingBooleanfalseDisable formatting the phone number in the input, the formatted result still be accessible by formattedNumber returned from onInput event
placeholderstringEnter a phone numberPlaceholder for the input
requiredBooleanfalseRequired property for HTML5 required attribute
enabledCountryCodeBooleanfalseEnable country code in the input
enabledFlagsBooleantrueEnable flags in the input
preferredCountriesArray[]Preferred countries list, will be on top of the dropdown. ie ['AU', 'BR']
onlyCountriesArray[]List of countries will be shown on the dropdown. ie ['AU', 'BR']
ignoredCountriesArray[]List of countries will NOT be shown on the dropdown. ie ['AU', 'BR']
autocompleteString'on'Native input 'autocomplete' attribute
nameString'telephone'Native input 'name' attribute
maxLenNumber25Native input 'maxlength' attribute
wrapperClassesString''Custom classes for the wrapper
inputClassesString''Custom classes for the input
dropdownOptionsObject{ disabledDialCode: false }Options for dropdown, supporting disabledDialCode
inputOptionsObject{ showDialCode: false }Options for input, always show dial code in the input

Events

Property valueArgumentsDescription
inputString, ObjectFires when the input changes with the argument is the object includes { number, isValid, country }
validateObjectFires when the correctness of the phone number changes (from true to false or vice-versa) and when the component is mounted { number, isValid, country }
blurFires on blur event
spaceFires on keyup.space event
enterFires on keyup.enter event

Highlights & Credits

Demo Usage


# install dependencies
$ yarn/npm install

# compile demo for development
$ yarn/npm dev

# open Browser and start serve in demo
$ yarn/npm demo:open

# compile dist demo
$ yarn/npm dist:demo

# compile dist
$ yarn/npm dist

Typescript Support

If you working with typescript will need declaration requirements.

npm install --save-dev @types/vue-tel-input

Contributors

made with ❤ by Steven.

Keywords

FAQs

Package last updated on 07 Jun 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc