Skip to content

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.

VueReact

Current tags: Vue, React

Basic Usage

Disabled State

Use the disabled attribute to disable the input field.

Tag 1Tag 2
Disabled State

Limit Count

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

Inputted 0 / 5 tags

Limit Count

Clearable

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

JavaScriptTypeScript
Clearable

Collapsible Tags

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

use collapse-tags:

Tag 1 + 4

use collapse-tags-tooltip:

Tag 1 + 4

use max-collapse-tags:

Tag 1Tag 2Tag 3 + 2
Collapsible Tags

Draggable Sorting

Use the draggable attribute to sort tags by dragging.

Draggable 1Draggable 2Draggable 3Draggable 4

Drag tags to change order

Draggable Sorting

Prefix and Suffix

Use prefix and suffix attributes to add prefix and suffix.

Tag:
VueReact
VueReact
units
Prefix and Suffix

Tag Effect

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

Tag One
Tag One
Tag One
Tag Effect

Different Sizes

Use the size attribute to control the input size.

Tag One
Tag One
Tag One
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.

SSRNuxt 3
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

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

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

Released under the MIT License.