InputTag

Enter an array of tags

Use

Basic Use

When using pro-input-tag, most attribute of type="text" are supported

<template>
  <pro-input-tag
    v-model="inputTags"
    placeholder="Please click the Enter button after input"
  />
</template>

<script>
import { defineComponent, ref } from 'vue'

export default defineComponent({
  setup() {
    const inputTags = ref([])

    return {
      inputTags,
    }
  },
})
</script>

Trigger

TIP

Since 1.0.0, The default trigger mode is adjusted to Enter

Input is triggered by the space bar by default, Set trigger="enter" attribute to enable trigger by Enter

<template>
  <pro-input-tag
    v-model="inputTags"
    trigger="space"
    placeholder="Please click the space button after input"
  />
</template>

<script>
import { defineComponent, ref } from 'vue'

export default defineComponent({
  setup() {
    const inputTags = ref([])

    return {
      inputTags,
    }
  },
})
</script>

Limit max tags

The max number of tags that can be entered can be configured through max

<template>
  <pro-input-tag
    v-model="inputTags"
    :max="3"
    placeholder="Enter up to 3 tags"
  />
</template>

<script>
import { defineComponent, ref } from 'vue'

export default defineComponent({
  setup() {
    const inputTags = ref([])

    return {
      inputTags,
    }
  },
})
</script>

Component Size

Set size attribute to change the size of Input and Tag

<template>
  <pro-input-tag
    v-for="item in sizeList"
    :key="item"
    v-model="inputTags"
    :size="item"
    placeholder="Please click the Enter button after input"
    class="input-tag-size"
  />
</template>

<script>
import { defineComponent, ref } from 'vue'

export default defineComponent({
  setup() {
    const inputTags = ref([])
    const sizeList = ['large', 'default', 'small']

    return {
      inputTags,
      sizeList,
    }
  },
})
</script>

<style>
.input-tag-size {
  margin-bottom: 10px;
}
.input-tag-size:last-child {
  margin-bottom: 0;
}
</style>

Props

NameDescriptionTypeOptionsDefault
v-modelbinding valuearray--
triggerthe key to trigger input tagstringspace / enterenter
maxmax number tags that can be enternumber--
sizecomponent sizestringlarge / default /small-
typetag Typestringsuccess / info / warning / danger-
hitwhether Tag has a highlighted borderboolean-false
colorbackground color of the Tagstring--
effectcomponent theme of the Tagstringdark / light / plainlight
maxlengthmaximum Input text lengthnumber--
minlengthminimum Input text lengthnumber--
show-word-limitwhether show word countboolean-false
placeholderplaceholder of Inputstring--
clearablewhether to show clear buttonboolean-false
disabledwhether disabledboolean-false
prefix-iconprefix icon classstring--
suffix-iconsuffix icon classstring--
autocompletesame as autocomplete in native inputstringon / offoff
namesame as name in native inputstring--
readonlysame as readonly in native inputboolean-false
autofocussame as autofocus in native inputboolean-false
formsame as form in native inputstring--
labellabel textstring--
tabindexinput tabindexstring--
validate-eventwhether to trigger form validationboolean-true
input-stylethe style of inputobject--

Events

NameDescriptionParameters
inputtriggers when the Input value change(value: string)
tag-addtriggers when add a tag(value: string)
tag-removetriggers when close button is clicked(value: string)