# InputTag
Type text and press the trigger key to create tags. Supports × removal, Backspace deletion of the last tag, and max / duplicate controls.
InputTag
<template>
<div class="demo-col" style="gap: 18px;">
<div class="demo-row" style="gap: 12px; flex-wrap: wrap; align-items: flex-start;">
<div style="width: 320px;">
<p class="demo-note">Default (Enter to submit)</p>
<LhInputTag v-model="tags" />
</div>
<div style="width: 320px;">
<p class="demo-note">Comma trigger, max 3</p>
<LhInputTag v-model="tags2" trigger="comma" :max="3" />
</div>
</div>
<div class="demo-row" style="gap: 12px; flex-wrap: wrap; align-items: flex-start;">
<div style="width: 320px;">
<p class="demo-note">Duplicates allowed</p>
<LhInputTag v-model="tags3" allow-duplicate placeholder="Duplicate tags are also accepted" />
</div>
<div style="width: 320px;">
<p class="demo-note">Disabled / readonly</p>
<LhInputTag v-model="tags" disabled style="margin-bottom: 8px;" />
<LhInputTag v-model="tags" readonly />
</div>
</div>
<p class="demo-note">Current tags: {{ tags.join(', ') || '(empty)' }}; comma group: {{ tags2.join(', ') || '(empty)' }}</p>
</div>
</template>
<script>
export default {
data() {
return { tags: ['Ink wash', 'Gongbi'], tags2: ['Colophon'], tags3: [] }
},
}
</script>
# Props
| Prop | Description | Type | Default |
|---|---|---|---|
| value (v-model) | Tag list | string[] | [] |
| trigger | Key that submits a tag | 'enter' \| 'space' \| 'comma' | 'enter' |
| max | Tag limit (non-positive means unlimited) | number | — |
| allowDuplicate | Allow duplicate tags | boolean | false |
| disabled | Disable | boolean | false |
| readonly | Read-only (no tag creation, no delete keys, no input rendered) | boolean | false |
| placeholder | Placeholder text | string | Locale message |
| sx | sx shorthand layout props | — | — |
# Events
| Event | Description | Callback args |
|---|---|---|
| input | v-model (Vue 2 semantics) | (tags: string[]) |
| change | Tag set changed | (tags: string[]) |
| insert-reject | Submission rejected (empty / duplicate / over max); lets the UI decide whether to notify | (reason: 'empty' \| 'duplicate' \| 'max') |
# Interaction conventions
- Backspace: deletes the last tag when the input is empty (ignored when readonly / disabled)
- Input is trimmed before submission; an empty result after trim does not create a tag
Copyright © 2024-2026 FengMo WenXue