• Stars
    star
    811
  • Rank 56,215 (Top 2 %)
  • Language
    CSS
  • License
    MIT License
  • Created almost 7 years ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

International Telephone Input with Vue

vue-tel-input-logo

vue-tel-input

International Telephone Input with Vue.

npm stars

In-action GIF

Documentation and Demo

Visit the website

Vue 2 Support

vue-tel-input@legacy: Guide

Changelog

Go to Github Releases

Getting started

  • Install the plugin:

    npm install vue-tel-input
  • Add the plugin into your app:

    import Vue from 'vue';
    import VueTelInput from 'vue-tel-input';
    import 'vue-tel-input/vue-tel-input.css';
    
    const app = createApp(App);
    app.use(VueTelInput);
    app.mount('#app');

    More info on installation

  • Use the vue-tel-input component:

    <template>
      <vue-tel-input v-model="phone"></vue-tel-input>
    </template>

Installation

npm

  npm install vue-tel-input

Install the plugin into Vue:

import { createApp } from 'vue';
import App from './App.vue';
import VueTelInput from 'vue-tel-input';
import 'vue-tel-input/vue-tel-input.css';

const globalOptions = {
  mode: 'auto',
};

const app = createApp(App);
app.use(VueTelInput, globalOptions); // Define default global options here (optional)
app.mount('#app');

View all available options in Props.

Or use the component directly:

<template>
  <vue-tel-input v-model="phone" mode="international"></vue-tel-input>
</template>

<script>
  import { ref } from 'vue';
  import { VueTelInput } from 'vue-tel-input';
  import 'vue-tel-input/vue-tel-input.css';

  export default {
    components: {
      VueTelInput,
    },

    setup() {
      const phone = ref(null);

      return {
        value,
      };
    },
  };
</script>

Browser

<script src="https://unpkg.com/vue-tel-input"></script>
<link rel="stylesheet" href="https://unpkg.com/vue-tel-input/dist/vue-tel-input.css" />

If Vue is detected in the Page, the plugin is installed automatically.

** Otherwise, manually install the plugin into Vue:

app.use(window['vue-tel-input']);

Component lazy loading

Since the library is about 200kb of JavaScript and 100kb of CSS in order to improve initial page loading time you might consider importing it asynchronously only when user navigates to the page where the library is actually needed. The technique is called Lazy Load and you can use it in some modern bundlers like Webpack and Rollup.

<!-- your-component.vue-->
<template>
  <vue-tel-input v-model="value"></vue-tel-input>
</template>
<script>
  const VueTelInput = () =>
    Promise.all([
      import(/* webpackChunkName: "chunk-vue-tel-input" */ 'vue-tel-input'),
      import(/* webpackChunkName: "chunk-vue-tel-input" */ 'vue-tel-input/vue-tel-input.css'),
    ]).then(([{ VueTelInput }]) => VueTelInput);

  export default {
    components: {
      VueTelInput,
    },
  };
</script>

As you see, we don't use Vue SFC <style></style> tag here to import component's css as it would result in CSS going to the main/vendors bundle instead of being downloaded on demand.

Development

Clone the project

  git clone https://github.com/iamstevendao/vue-tel-input.git

Go to the project directory

  cd vue-tel-input

Install dependencies

  npm install

Start the server

  npm run dev

License

Copyright (c) 2018 Steven Dao. Released under the MIT License.

made with ❤ by Steven.

More Repositories

1

vue-suggestion

Suggestion List Input with Vue
JavaScript
66
star
2

alfred-open-with-vscode

Alfred workflow for opening a folder with VS Code
46
star
3

alfred-open-with-sublime-merge

Alfred workflow for opening a git folder with Sublime Merge
3
star
4

naruto

Naruto Website, my project for Intro to Web assignment: https://iamstevendao.github.io/Naruto/html/
JavaScript
3
star
5

pacman_cpp

Pacman game built by C++ with SFML
C++
3
star
6

iamstevendao.com

https://iamstevendao.com
Vue
2
star
7

pacman

Pacman with pure Javascript and Dijkstra's Algorithm https://iamstevendao.github.io/pacman/
JavaScript
2
star
8

boilerplate-meteor-vue

Boilerplate for Meteor+Vue app (under construction)
JavaScript
2
star
9

afterall

Day Counting Android App (Sync with Google Calendar)
Java
2
star
10

superfast-dictionary

EN-VN Dictionary Android App https://play.google.com/store/apps/details?id=fukie.sieunhanhav
Java
2
star
11

who-let-the-dogs-out

JavaScript
2
star
12

dotfiles

My Visual Studio Code Settings
Python
2
star
13

snake

Snake with Phaser.io: https://iamstevendao.github.io/snake/
JavaScript
1
star
14

hello-redwood

TypeScript
1
star
15

alfred-chrome-bookmarks-with-profiles

Alfred workflow to open a Chrome bookmark using its profile
Python
1
star
16

filter-facebook-messages

1
star
17

images-search-abstraction-layer

Image Search Abstraction Layer with NodeJS
CSS
1
star
18

Naruto1

This is a website for my assignment.
HTML
1
star
19

express-vue-starter

A fork from Hackathon-starter with Vue as client
JavaScript
1
star
20

CarrProject

JavaScript
1
star
21

email-sender-service

Email Sender Service (Cabcharge Full Stack Dev Challenge)
CSS
1
star
22

javascript-shortcuts

Shortcuts for Javascript
1
star
23

meteor-vue-demo

Meteor + Vue Todos App
HTML
1
star
24

gracy

Yet another minimal Jekyll theme (under construction)
CSS
1
star
25

url-shortener

URL Shortener Microservice https://iamsd-url-shortener.glitch.me/
CSS
1
star
26

portfolio

My portfolio website https://iamstevendao.github.io/portfolio/
HTML
1
star
27

fcc-backend

FreeCodeCamp BackEndCertificate
JavaScript
1
star
28

email-sender

Email sender (Express + Vue)
JavaScript
1
star
29

numpad-screen

Numpad and Contact Screen for Android App
1
star
30

MonkeyMaths

https://projects.iamstevendao.com/monkeymaths/
TypeScript
1
star