Skip to content
API 风格:

InputTag Tag Input ​

LhInputTag tag input: press Enter to add a tag, Backspace to remove the last one, with configurable trigger, max count and duplicate control.

Basic Usage ​

Basic Usage
VueVite
vue
<script setup lang="ts">
import { ref } from 'vue'
import { LhInputTag } from '@lh-ui/vue3'

const tags = ref(['Vue', 'Vite'])
const t1 = {
  placeholder: 'Type and press Enter',
}
</script>

<template>
<LhInputTag v-model="tags" :placeholder="t1.placeholder" />
</template>
vue
<script>
import { LhInputTag } from '@lh-ui/vue3'

export default {
  components: { LhInputTag },
  data() {
    return {
      tags: ['Vue', 'Vite'],
      t1: {
      placeholder: 'Type and press Enter',
    },
    }
  },
}
</script>

<template>
<LhInputTag v-model="tags" :placeholder="t1.placeholder" />
</template>
Trigger & Max
vue
<script setup lang="ts">
import { ref } from 'vue'
import { LhInputTag } from '@lh-ui/vue3'

const tags2 = ref([])
const t2 = {
  placeholder2: 'Space to add, max 5',
}
</script>

<template>
<LhInputTag v-model="tags2" trigger="space" :max="5" :placeholder="t2.placeholder2" />
</template>
vue
<script>
import { LhInputTag } from '@lh-ui/vue3'

export default {
  components: { LhInputTag },
  data() {
    return {
      tags2: [],
      t2: {
      placeholder2: 'Space to add, max 5',
    },
    }
  },
}
</script>

<template>
<LhInputTag v-model="tags2" trigger="space" :max="5" :placeholder="t2.placeholder2" />
</template>

InputTag API ​

Props ​

NameDescriptionTypeDefault
modelValueTag list (v-model)string[]() => []
triggerSubmit trigger key: enter / space / comma"enter" | "space" | "comma"'enter'
placeholderPlaceholderstring''
maxMax tag count (non-positive = unlimited)number0
allowDuplicateAllow duplicate tagsbooleanfalse
readonlyRead-onlybooleanfalse
disabledDisabledbooleanfalse
ariaLabelAccessibility name of the inputstring—
sxQuick layout propsLhSxProps—

Events ​

NameDescriptionType
update:modelValueFired when the tag list changes(value: string[])
changeFired when the tag list changes(value: string[])
addFired when a tag is added(tag: string)
removeFired when a tag is removed(tag: string)

Accessibility ​

  • The input has an aria-label; each remove button announces the removed tag
  • Backspace removes the last tag when the input is empty

Type Definitions ​

The TypeScript type structures exported by this component (auto-extracted from packages/components/input-tag/src/types.ts and @lh-ui/share/core/* sources; click each entry to expand; see the Props table above for attribute descriptions):

LhInputTagProps
ts
export interface LhInputTagProps {
  modelValue?: string[]
  trigger?: LhInputTagTrigger
  placeholder?: string
  max?: number
  allowDuplicate?: boolean
  readonly?: boolean
  disabled?: boolean
  ariaLabel?: string
  sx?: LhSxProps
}

Beauty of tradition, foundation of code