vue3-headless-tel-input
Installation
998
5
| Install | |
|---|---|
npm install vue3-headless-tel-input |
|
| Latest Version: | 0.0.18 |
| Vue: | 3 |
| License: | MIT |
| Last Updated: | Jun 20, 2023 |
| Links: | GitHub · npm |
Maintainer: mirjalol2401
Vue 3 headless tel input docs
Installation
With npm
npm install vue3-headless-tel-input
With yarn
yarn add vue3-headless-tel-input
Usage
Import composable and give returned ref to the input
import { useTelInput } from "vue3-headless-tel-input"
const {
inputRef,
countries, selectedCountry, selectedCountryObject,
value, unmaskedValue
} = useTelInput(input)
Template part
<template>
<div>
<select v-model="selectedCountry">
<option v-for="country in countries" :key="country.code" :value="country.code">
{{ country.callingCode }}
</option>
</select>
<input ref="inputRef" />
</div>
</template>
Vue component example with v-model
<script setup>
import { toRef, watch } from "vue"
import { useTelInput } from "vue3-headless-tel-input"
const props = defineProps({
modelValue: String,
default: undefined
});
const emit = defineEmit(["update:model-value"])
const value = toRef(props, "modelValue");
const { inputRef, selectedCountry, selectedCountryObject, unmaskedValue } = useTelInput(value);
watch(unmaskedValue, () => {
emit("update:model-value", unmaskedValue.value);
});
</script>
<template>
<div>
<select v-for="country in countries" :key="country.code" v-model="selectedCountry">
<option :value="country.code">
{{ country.name.common }} {{ country.callingCode }}
</option>
</select>
<input ref="inputRef" />
</div>
</template>
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
Version History
| Version | Released | Vue | License |
|---|---|---|---|
| 0.0.18 | ^3.3.4 | MIT | |
| 0.0.17 | ^3.2.33 | MIT | |
| 0.0.16 | ^3.2.33 | MIT | |
| 0.0.15 | ^3.2.45 | MIT | |
| 0.0.14 | ^3.2.45 | MIT | |
| 0.0.13 | ^3.2.45 | MIT | |
| 0.0.12 | ^3.2.45 | MIT | |
| 0.0.11 | ^3.2.45 | MIT | |
| 0.0.10 | ^3.2.45 | MIT | |
| 0.0.9 | ^3.2.45 | MIT | |
| 0.0.8 | ^3.2.45 | MIT | |
| 0.0.7 | ^3.2.45 | MIT | |
| 0.0.6 | ^3.2.45 | MIT | |
| 0.0.5 | ^3.2.45 | MIT | |
| 0.0.4 | ^3.2.45 | ||
| 0.0.3 | ^3.2.45 | ||
| 0.0.2 | ^3.2.45 | ||
| 0.0.1 | ^3.2.45 | ||
| 0.0.0 | ^3.2.45 |