Skip to content
Latestv1.0.63

InputTag ​

Used for inputting and managing multiple tags.

Basic Usage ​

Bind a tag array with v-model. Press Enter or , to confirm input and add a tag.

Basic Usage

Disabled State ​

Use the disabled attribute to disable the input field.

Disabled State

Limit Count ​

Use the max attribute to limit the maximum number of tags.

Limit Count

Clearable ​

Use the clearable attribute to enable one-click clear functionality.

Clearable

Collapsible Tags ​

Use the collapse-tags attribute to collapse multiple tags. Combine with collapse-tags-tooltip to show all tags on hover.

Collapsible Tags

Draggable Sorting ​

Use the draggable attribute to sort tags by dragging.

Draggable Sorting

Prefix and Suffix ​

Use prefix and suffix attributes to add prefix and suffix.

Prefix and Suffix

Tag Effect ​

Use tag-effect to set the display effect of tags.

Tag Effect

Different Sizes ​

Use the size attribute to control the input size.

Different Sizes

Use in Nuxt ​

InputTag is fully compatible with Nuxt 3/4. In SSR scenarios, existing tags (modelValue) are rendered directly as static HTML tags on the server, ensuring visual consistency on the first screen and being SEO-friendly.

Use in Nuxt

SSR Notes:

  • ✅ Initial tag array is fully supported for SSR synchronous rendering.
  • ✅ Tag styles, themes (tag-effect), and sizes support server-side rendering.
  • ✅ Prefix/suffix text and icons are placed and displayed on the server.
  • ⚠️ Dynamic addition (Enter confirmation), draggable sorting, and deleting tags take effect after client-side activation (Hydration).
  • 💡 Virtual scrolling (for extremely long tag lists, if enabled) renders the basic visible part on the server.

SSR Performance Optimization

When rendered on the server, the InputTag component dynamically generates optimized HTML fragments based on the length of modelValue, reducing the DOM diff calculations during client hydration and improving interaction response speed.

API ​

Props ​

PropDescriptionTypeDefault
model-value / v-modelBinding value (Tag array)string[][]
typeTag type'primary' | 'success' | 'warning' | 'danger' | 'info''info'
sizeSize'large' | 'default' | 'small''default'
disabledWhether to disablebooleanfalse
readonlyWhether to set read-onlybooleanfalse
maxMaximum number of tagsnumber—
separatorSeparatorstring | string[][',', 'Enter']
placeholderPlaceholderstring—
clearableWhether it is clearablebooleanfalse
add-on-blurWhether to add input content on blurbooleantrue
closableWhether tags are closablebooleantrue
validate-tagValidation function(value: string) => boolean—
trimWhether to trim whitespacebooleantrue
allow-duplicateWhether to allow duplicate tagsbooleanfalse
collapse-tagsWhether to collapse tagsbooleanfalse
collapse-tags-tooltipWhether to show tooltip when collapsedbooleanfalse
max-collapse-tagsMaximum number of tags to show before collapsingnumber1
draggableWhether draggable sorting is enabledbooleanfalse
tag-effectTag effect'dark' | 'light' | 'plain''light'
prefixPrefix textstring—
suffixSuffix textstring—
prefix-iconPrefix iconComponent—
suffix-iconSuffix iconComponent—

| theme-overrides | Component-level theme overrides | ComponentThemeVars | undefined |

Events ​

Event NameDescriptionCallback Parameters
changeTriggered when tags change(value: string[]) => void
inputTriggered on input(value: string) => void
addTriggered when a tag is added(tag: string) => void
removeTriggered when a tag is removed(tag: string, index: number) => void
focusTriggered on focus(event: FocusEvent) => void
blurTriggered on blur(event: FocusEvent) => void
clearTriggered on clear() => void
drag-endTriggered when dragging ends(tags: string[]) => void

Slots ​

Slot NameDescriptionScoped Parameters
prefixCustom prefix content—
suffixCustom suffix content—
tagCustom tag content{ tag: string, index: number, close: () => void }
clear-iconCustom clear icon—
collapse-tagCustom collapsed tag content{ count: number, tags: string[] }

Expose ​

NameDescriptionType
focusFocus the input field() => void
blurBlur the input field() => void
clearClear all tags() => void

Theme Variables ​

YhInputTag supports themeOverrides. The component itself consumes the following tag-input CSS variables:

VariableDescriptionDefault
--yh-input-tag-min-heightMinimum heightvar(--yh-component-size-default)
--yh-input-tag-font-sizeFont sizevar(--yh-font-size-base)
--yh-input-tag-bg-colorBackground colorvar(--yh-fill-color-blank)
--yh-input-tag-border-colorBorder colorvar(--yh-border-color)
--yh-input-tag-tag-heightTag height22px
--yh-input-tag-gapTag gap4px

Type Exports ​

NameDescription
YhInputTagPropsProps type for YhInputTag
YhInputTagEmitsEmits type for YhInputTag
YhInputTagSlotsSlots type for YhInputTag
YhInputTagExposeExpose type for YhInputTag
YhInputTagSizeInput-tag size union
YhInputTagTypeInput-tag type union
YhInputTagInstancePublic instance type for YhInputTag

Released under the MIT License.