Skip to content

InputTag ​

A tag group that submits as you type, supporting trigger keys, a tag limit, deduplication and click-to-remove.

Basic usage ​

vue
<script setup>
import { ref } from 'vue'
const tags = ref(['ink', 'blank'])
</script>

<template>
  <lh-input-tag v-model="tags" placeholder="Type and press Enter to submit" />
</template>

Trigger keys ​

trigger accepts enter (default) / space / comma. When triggered by space / comma, the whitespace does not enter the input.

vue
<template>
  <lh-input-tag v-model="tags" trigger="comma" placeholder="Type a comma to submit" />
</template>

Limit and deduplication ​

vue
<template>
  <lh-input-tag v-model="tags" :max="3" allow-duplicate />
</template>

When max is a positive number it caps the tag count (submissions beyond the cap are rejected and the input is cleared); duplicates are rejected by default (a duplicate is not submitted).

Readonly and disabled ​

vue
<template>
  <lh-input-tag v-model="tags" readonly />
  <lh-input-tag v-model="tags" disabled />
</template>

Props ​

PropDescriptionTypeDefault
modelValueTag list (v-model)string[][]
triggerSubmit trigger key (always the done key on the Mini Program)'enter' | 'space' | 'comma''enter'
placeholderPlaceholder hint (shown only when there are no tags)string''
placeholderStylePlaceholder styling (replaces ::placeholder)string—
maxTag limit (a non-positive value means unlimited)number0
allowDuplicateAllow duplicate tagsbooleanfalse
readonlyReadonlybooleanfalse
disabledDisabledbooleanfalse
ariaLabelAccessibility namestring—
customClassCustom class namestring—
sxQuick layout propsLhSxProps—

Events ​

EventDescriptionParameters
update:modelValueTag list changed(value: string[])
changeTag list changed (same as modelValue)(value: string[])
addA single tag submitted(tag: string)
removeA single tag removed(tag: string)

Methods (defineExpose) ​

MethodDescription
focusFocus the input
commitSubmit the current input

Platform differences ​

CapabilityH5Mini Program
Submit trigger keyAll trigger values supported (Enter / Space / Comma keyboard events)Always the done key (@confirm); the space / comma trigger keys are H5-only
Backspace removalBackspace removes the last tag when the input is emptyNo keyboard events; removal goes through the × button on each tag (available on both platforms)
Commit on blurYesYes
Focus border:has() focus styling appliesNo focus border (WXSS does not support :has()); input works normally