Skip to content

MaskInput

MaskInput builds upon TInput by integrating IMask.js to provide input formatting capabilities — ideal for phone numbers, dates, credit cards, and other fields requiring fixed formatting.

Basic Usage

Use the mask prop to define the input format. v-model provides two-way binding with the formatted value.

vue

<TMaskInput mask="000-0000-0000" placeholder="000-0000-0000"/>
<TMaskInput mask="00/00/0000" placeholder="00/00/0000"/>
<TMaskInput mask="0000 0000 0000 0000" placeholder="0000 0000 0000 0000"/>
<TMaskInput mask="00:00" placeholder="00:00"/>

Telephone Mask

Tabler's typical usage: telephone mask with international format.

vue

<TMaskInput mask="(00) 0000-0000" placeholder="(00) 0000-0000" autocomplete="off"/>

Two-way Binding

v-model binds to the formatted value. Note that IMask returns the formatted string.

View Code
vue

<script setup lang="ts">
import { ref } from 'vue'

const phone = ref('')
</script>
<template>
  <TMaskInput v-model="phone" mask="000-0000-0000" placeholder="000-0000-0000"/>
  <div>Formatted value: {{ phone }}</div>
</template>

Advanced Masks

The mask prop supports all IMask mask types, including number ranges and regex patterns.

View Code
vue

<TMaskInput :mask="{ mask: Number, min: 0, max: 100 }" placeholder="0-100"/>
<TMaskInput :mask="{ mask: Number, min: 0, max: 100, scale: 0, suffix: '%' }" placeholder="0-100%"/>

Composing with TInput Features

TMaskInput inherits all TInput features including icons, sizes, rounded style, and validation states.

View Code
vue

<TMaskInput size="lg" mask="000-0000-0000" placeholder="000-0000-0000"/>
<TMaskInput size="sm" rounded mask="000-0000-0000" placeholder="000-0000-0000"/>
<TMaskInput disabled mask="000-0000-0000" placeholder="000-0000-0000"/>
<TMaskInput validation="invalid" mask="000-0000-0000" placeholder="000-0000-0000"/>

API

TMaskInput Props

PropDescriptionTypeDefault
maskMask rule (string or IMask config object)string | Record<string, any>
typeNative input typestring'text'
placeholderPlaceholder textstringundefined
sizeInput size'sm' | 'lg'undefined
roundedPill/rounded stylebooleanfalse
flushBorderless stylebooleanfalse
disabledDisabled statebooleanfalse
readonlyReadonly statebooleanfalse
maxlengthMax character lengthnumberundefined
nameNative name attributestringundefined
idNative id attributestringundefined
autocompleteAutocomplete hintstringundefined
requiredWhether requiredbooleanfalse
prepend-iconPrepend icon (Tabler icon component)Iconundefined
append-iconAppend icon (Tabler icon component)Iconundefined
prepend-textPrepend textstringundefined
append-textAppend textstringundefined
validationValidation state'valid' | 'invalid'undefined
blockFull width (w-100)booleanfalse

TMaskInput Emits

EventDescriptionCallback
update:modelValueTriggered when input value changes (formatted)(value: string) => void

TMaskInput Slots

SlotDescription
prependPrepend content (appears before <input>)
appendAppend content (appears after <input>)