Skip to content

Tags Input

Enter and manage a list of tags.

Demos

Size
Variant
Vue
Tailwind

Usage

vue
<script setup lang="ts">
import { Accordion } from '~/components/ui/accordion'

const items = [
  { value: 'source', label: 'Do I own the source?', content: 'Yes. Copy and adapt the files.' },
]
</script>

<template>
  <Accordion :items="items" />
</template>

Installation

Complete the shared installation. Copy TagsInput.vue and index.ts into app/components/ui/tags-input/.

API

Variants and defaults

PropValuesDefault
sizexs, sm, md, lg, xlsm
variantoutline, soft, bareoutline

Size scales the tags and the field together. The text-side inset balances the visible space around the remove icon; increasing size grows the tag rather than adding empty space around it.

SizeField minimumTag heightTextRemove icon
xs24px20px12px12px
sm28px22px13px14px
md32px24px14px16px
lg36px28px14px18px
xl40px32px16px20px

The field grows when tags wrap. Touch removal targets remain at least 44px while their icons keep the selected size.

Models

ModelTypeDefaultDescription
v-modelTagsInputValue[][]Accepted tag values.
v-model:inputstring""Current uncommitted text.

Props

PropTypeDefaultDescription
displayValue(value) => stringstring/JSONVisible and accessible tag label.
convertValue(text) => valueidentity stringConverts input text before validation/addition.
serializeValue(value) => stringstring/JSONSerializes native form values and keys.
isEqual(a, b) => booleanObject.isDuplicate and equality comparison.
validate(value) => booleanaccepts allValidates converted values.
delimiterstring | RegExp","Add key and paste splitting rule.
addOnBlurbooleanfalseAdds non-empty input on blur.
addOnPastebooleanfalseAdds multiple delimited clipboard values.
addOnTabbooleanfalseAdds non-empty input instead of moving focus.
duplicatebooleanfalseAllows equal values more than once.
maxnumber0Maximum count; zero means unlimited.
trimbooleantrueTrims input and pasted segments.
clearablebooleanfalseRenders a clear-all button when values exist.
placeholderstring-Editable input placeholder.
maxLengthnumber-Native character limit for uncommitted input text.
autoFocusbooleanfalseFocuses the editable input after mount.
idstringfield/generated idEditable input id.
namestringfield nameNative form field name repeated per tag.
requiredbooleanfalseRequires at least one tag.
disabledbooleanfalseDisables editing, controls, and form submission.
readOnlybooleanfalseKeeps values focusable but prevents changes.
invalidbooleanfalseForces invalid styling and ARIA state.
dir"ltr" | "rtl""ltr"Tag direction and Arrow-key behavior.
ariaLabelstring"Tags input"Accessible group/input label.
ariaLabelledbystring-Accessible label element id.
ariaDescribedbystringfield IDsAccessible description/error ids.
uiTagsInputUi-Classes for structural parts.

Slots

SlotPropsDescription
tagvalue, label, index, isHighlighted, removeComplete custom tag.
deletevalue, indexDefault remove button content.
inputvalue, inputProps, addCustom editable input. Bind inputProps.
clear-Clear-all button content.

Events

EventPayloadDescription
value-change(values, details)Fires before the values array updates. Cancelable.
input-change(text, details)Fires before editable text updates. Cancelable.
add(value, details)Fires before an accepted value is added. Cancelable.
remove(value, details)Fires before a value is removed. Cancelable.
invalid-value(value, details)Reports empty, convert, invalid, duplicate, or max reasons.

Keyboard

KeyBehavior
Enter / delimiter keyAdd current text.
TabAdd when addOnTab; otherwise move focus normally.
input BackspaceFocus last tag when input is empty.
input boundary ArrowFocus last tag from the start edge, respecting dir.
tag ArrowLeft / ArrowRightMove between tags/input, respecting dir.
tag Home / EndFocus first/last tag.
tag Backspace / DeleteRemove focused tag and retain logical focus.
tag EscapeReturn focus to the editable input.