Tags Input

new

Words that got promoted to badges. Type a tag, press Enter, and it turns into a badge. All in one text field.

Demo
AppleBanana

Open Props in the corner of the example to try variant, size and disabled.

The five text control variants, the same as on Input.

The frame starts at the input's height for its size, from 28px at xs to 48px at xl, and the tags take the badge size that fits: 20px at xs, 24px at sm and md, 28px at lg, 32px at xl. Their radius is concentric with the frame's.

Installation

Usage

<script setup lang="ts">
import { TagsInput, TagsInputInput, TagsInputItem, TagsInputItemDelete, TagsInputItemText } from '@/components/ui/tags-input'

const fruits = ref(['Apple', 'Banana'])
</script>

<template>
  <TagsInput v-model="fruits">
    <TagsInputItem v-for="fruit in fruits" :key="fruit" :value="fruit">
      <TagsInputItemText />
      <TagsInputItemDelete />
    </TagsInputItem>
    <TagsInputInput placeholder="Add a fruit" aria-label="Fruits" />
  </TagsInput>
</template>
  • TagsInput: the frame, same as Input; grows as tags wrap
  • TagsInputItem: one per tag, a Badge with TagsInputItemText and TagsInputItemDelete
  • TagsInputInput: the text box; attributes like placeholder go here

Enter or a comma turns the text into a tag. Want another separator? Pass a character or a regex to delimiter. Backspace in an empty box selects the last tag; press it again to remove it.

Duplicates and tags over max are refused, and invalid fires. To allow duplicates, turn on duplicate.

Set name, and the tags submit with the form. Give the input an aria-label, or put it in a Field.

Examples

Paste and limits

delimiter takes a regular expression, so a comma, a semicolon or a space all end a tag; addOnPaste splits pasted text on it and addOnBlur keeps what was typed when focus leaves. max caps the count, and invalid reports what was refused.

Paste and limits
ada@example.com

1 of 5. Comma, space or Enter adds one; paste a list.

Objects

With objects in v-model, convertValue turns the typed text into one and displayValue picks the text to show. A tag takes a badge variant and color of its own.

With objects
BugGood first issue

bug, good-first-issue

In a field

Label, description and error come from the field. The label focuses the text box, required marks it, and invalid turns the frame destructive.

In a form, Enter adds the typed text as a tag and never submits; with nothing typed, it submits the form. Reka UI before 2.11 cancels that Enter a tick late, so TagsInputInput holds the form's submit back itself while there's a draft. To validate the tags with a schema, see VeeValidate.

In a field
TypeScript

Press Enter after each one.

API Reference

Every part accepts class, merged over its base classes.

Data attributes

data-slotAttributesDescription
tags-inputdata-variant, data-size, data-disabled, data-focused, data-invalidThe frame, holding the hidden form input. data-invalid while a refused tag is still in the text box.
tags-input-itemdata-variant, data-color, data-state, data-disabledOne tag, a badge. data-state="active" while selected from the keyboard.
tags-input-item-text—The tag's text, which labels its delete button.
tags-input-item-deletedata-state, data-disabledThe button that removes the tag, out of the tab order.
tags-input-inputdata-invalid, aria-invalidThe text box.

CSS variables

VariableDefaultDescription
--frame-radius--radius-control-md at mdThe frame's radius for its size. Tags take this less their distance from the edge, but never less than half of it. Set --control-radius to change every control at once.
--control-padding12pxWhere the text starts from the frame's edge while there are no tags, as in Input.
--tags-inset6pxThe tags' distance from the frame's outer edge, per size.

Keyboard

KeyAction
EnterTurns the typed text into a tag. Tab does too with addOnTab.
BackspaceIn an empty text box, selects the last tag; pressed again, removes it.
ArrowLeft / ArrowRightMoves the selection through the tags, and back to the text box past the last one.
Home / EndSelects the first or last tag.
DeleteRemoves the selected tag.

Changelog

  1. registry 0.21.0

    95a0fa1 — Parts follow their root's size through CSS variables instead of the context, so a class on a part wins over the size. PinInput sets --pin-input-slot, TagsInput --tags-input-line and --tags-input-delete, and PinInput, InputNumber, TagsInput and InputGroup set --control-text and --control-text-leading for the field inside (textControlText and textControlInnerText in @/ui/input). NavigationMenu's triggers and links read the --nav-* variables of the menu instead of setting their own, and DataTable's sort buttons and row toggles shrink at xs through the table's variables. PinInput's slots now sit --control-gap-* apart (2px wider at sm, lg and xl); nothing else moves. inputNumberInputVariants, tagsInputInputVariants and tagsInputItemDeleteVariants became the strings inputNumberInput, tagsInputInput and tagsInputItemDelete, inputGroupControlText is gone, and pinInputSlotVariants lost its size key.

  2. registry 0.18.0

    779955e — Corners come in three roles: rounded-control-*, rounded-surface-* and rounded-item-*, each scaled from --radius and tunable on its own with --control-radius, --surface-radius and --item-radius, on :root or any element. Every component uses them, and cn() merges them, so a class prop still wins.

    - --control-radius was the Input family's frame variable. It now sets every control, and the frames use --frame-radius. - Nested parts no longer turn square at small radii: the InputGroup button, the InputNumber steppers, the TagsInput chips, the DatePicker trigger and the Toast and Tour close buttons. - Menus, lists, pill tabs, the menubar and the toolbar wrap their corners around their items. Pill tabs are rounder (12/8px at md instead of 8/4px), menus and lists grow by up to 2px, and their rows at sizes xs and xl follow their height. Item sm takes 8px instead of 6.4px.

  3. registry 0.15.0

    d09f26a — Pressable parts ripple on their own: Button, Toggle, ToggleGroupItem, Item as a link or a button, the calendar days, tabs, accordion, menubar and navigation menu triggers, the items of Menu, Menubar, Select, Combobox, Command, DrawerMenu, Listbox and Tree, and the clear buttons of TagsInput and Combobox. Each imports the directive from @/lib/ripple, so add brings the ripple item along and nothing needs registering. On menu, listbox and tree rows the wave replaces the pressed layer, as state-layer already did. Bind v-ripple="false" on a Button to turn one off, or set --kappa-ripple: none on :root to turn them all off.

  4. registry 0.13.0

    d71e3ef — Forms with VeeValidate and Zod. New standard-schema lib item with toTypedSchema, which lets VeeValidate 4 validate with Zod 4, Valibot or any other Standard Schema: VeeValidate 4 passes a raw Zod 4 schema without a single error, and @vee-validate/zod throws on Zod 4 unions. Each issue lands at its field's path, such as emails[0].address. New examples bind every kind of control: a bug report, a select and combobox, choice groups, number, tags, pin and range inputs, a field array, an invite dialog with an error from the server, and VeeValidate's own Form and Field components through the slot.

    lib/field-context exports focusFirstInvalid(root), which moves focus to the first invalid control in page order once the errors have rendered: the input, the select trigger, the slider thumb, or the box Tab would reach in a checkbox or radio group. A control that can't take focus, such as one in a hidden tab, is skipped. It works with any validation.

    TagsInputInput no longer lets the form submit when Enter adds a tag on reka-ui 2.10, which cancels that Enter a tick late (unovue/reka-ui#2966). On reka-ui 2.11 nothing changes.

  5. registry 0.12.0

    c79028b — The control scale is now a set of tokens: --control-height-*, --control-padding-*, --control-icon-* and --control-gap-* for xs to xl, added to :root by the tokens item. Button, Input, InputFloating, Select, Combobox, InputNumber, TagsInput, PinInput, InputTime, InputGroup, Menu, Tabs, ColorPicker and Pagination read them, so overriding one on :root resizes every control of that size.

    Some sizes that strayed from the scale now follow it. Button icons are 20px at lg and xl instead of 16px, and so are the icons of Toggle, ToggleGroup, Toolbar and Pagination at those sizes. The gap between an icon and its label is 6, 8, 8, 10 and 12px from xs to xl, about half the icon, everywhere that has one: Button and the components built on it (where it was 4, 6, 8, 8 and 8px), Menu items and the Select, Combobox and Command lists (8, 10, 12, 12 and 12px), and Tabs triggers (6, 8, 8, 8 and 10px). Inset and checkbox or radio items move their labels with it, so they stay in line with items that have an icon. Everything else keeps its size.

  6. registry 0.11.0

    The text control frame of InputGroup, InputNumber, TagsInput and the Combobox anchor ignores what sits in an InputGroupAddon: a disabled checkbox's hidden form input no longer greys the frame or fades the addons, and the browser focusing it after a failed submit no longer lights the frame. A focused control that fails native validation shows the destructive edge again instead of the focus one.

  7. registry 0.10.0

    e03458c — The text control frame of InputGroup, InputNumber, TagsInput and the Combobox anchor reads focus, invalid and disabled from any input, textarea or role="spinbutton" inside it, not only from a direct child. An InputGroupAddon click focuses the first segment of a segmented control, and addons fade when any input inside the group is disabled.

  8. registry 0.9.0

    a7aad5f — New TagsInput: tags typed into one text control frame over Reka UI's TagsInput, with TagsInputItem chips drawn as badges, TagsInputItemText, TagsInputItemDelete and TagsInputInput parts, in Input's variants and sizes, with delimiter, paste, max and duplicate handling, wired to a surrounding Field.