Components

Tag Group

A group of colorful tags that can be selected, removed and navigated with the keyboard.

Source code

Click to see the source code for this component on GitHub. Feel free to copy it and adjust it for your own use.

Installation

To use the tag group as a field inside a Vee-Validate form, see VeeTagGroup.

Tag Group vs. Badge vs. Tags Input

Tag GroupBadgeTags Input
PurposeA list of tags the user can focus, select or removeA static labelAn input where the user types new tags
KeyboardArrow keys, Home/End, typeahead, DeleteNoneTyping, arrow keys, Backspace
SelectionNone, single or multipleNoNo
Colors30 colors, 4 variants30 colors, 12 variantsNeutral

Use a tag group for filters, choice chips and removable lists. Use a badge for a status that does nothing, and a tags input when users create the tags themselves.

Usage

The group renders a grid that needs an accessible name, so always pass an aria-label (or aria-labelledby). Set color, variant, size and shape on the group to style every tag at once, and override any of them on a single tag. The text of a tag is the default slot, which is also used for typeahead.

<template>
  <UiTagGroup v-model="selected" aria-label="Topics" selection-mode="multiple" color="indigo">
    <UiTagGroupItem value="vue" icon="logos:vue">Vue</UiTagGroupItem>
    <UiTagGroupItem value="nuxt" color="green" removable>Nuxt</UiTagGroupItem>
  </UiTagGroup>
</template>
Removing needs @remove
Tags are only removable when the group listens to @remove. The group does not delete anything itself, it tells you which values were removed and you update your own list. Without the listener, removable buttons and the Delete key do nothing.

Examples

Basic

A removable list. removable shows the remove button of a tag and the group emits remove with the values to delete. Focus a tag and press Delete or Backspace to remove it too.

Vue
Nuxt
TypeScript
Tailwind
Reka UI

Click the x, or focus a tag and press Delete or Backspace.

Colors

There are 30 colors: primary, the full Tailwind palette (red to rose, slate, gray, zinc, neutral, stone and the newer taupe, mauve, mist and olive) and the error, warning and success aliases. Every color has light and dark styles. They are shared with UiBadge through ~/utils/badge-colors, which also exports the badgeColors array.

primary
red
orange
amber
yellow
lime
green
emerald
teal
cyan
sky
blue
indigo
violet
purple
fuchsia
pink
rose
slate
gray
zinc
neutral
stone
taupe
mauve
mist
olive
error
warning
success

Variants

soft (default) is a tinted pill, solid is filled, outline only draws the border and modern is a neutral card where the color is used for the dot.

soft

gray
primary
red
orange
yellow
green
teal
blue
indigo
purple
pink

solid

gray
primary
red
orange
yellow
green
teal
blue
indigo
purple
pink

outline

gray
primary
red
orange
yellow
green
teal
blue
indigo
purple
pink

modern

gray
primary
red
orange
yellow
green
teal
blue
indigo
purple
pink

Sizes

Use size with sm, md (default) or lg.

sm
Design
Development
QA
md
Design
Development
QA
lg
Design
Development
QA

Shapes

Use shape="pill" (default) or shape="rounded".

Pill
Pill
Pill
Rounded
Rounded
Rounded
Rounded
Pill

Icons

icon renders an icon before the text and trailing-icon one after it. For anything else use the leading and trailing slots.

Verified
Pending
Failed
New
Docs
Pro
Beta

Dots

The modern variant shows a colored dot by default. Add dot to show one on any other variant (an avatar or icon replaces the default dot of modern).

Online
Away
Busy
Offline
Production
Staging
Development

Avatars

Use avatar to show an image before the text.

Kelly King
Ryan Author
Mia Chen

Single selection

Set selection-mode="single" and bind a value with v-model. Selected tags show a check mark and a stronger ring. Press Escape to clear the selection, or add disallow-empty-selection to prevent it.

XS
S
M
L
XL

Selected: M

Multiple selection

With selection-mode="multiple" the v-model is an array. Space and Enter toggle the focused tag.

Design
Code
Music
Travel
Food
Games

Selected: code

Add and remove

A tag group can be selectable and removable at once. When the focused tag is selected, Delete removes every selected tag.

urgent
frontend
bug
docs

Select several tags, then press Delete or Backspace to remove them together.

Custom content

The leading, trailing and delete slots receive { selected, disabled }, so the content can react to the state of the tag.

Free$0
Pro$12
Team$40

Disabled

Disable the whole group with disabled, or single tags. Disabled tags are skipped by keyboard navigation.

Locked
Locked
Available
Sold out
Available
Coming soon

Props

TagGroup

PropTypeDefaultDescription
v-modelT | T[]The selected tag(s). An array when selection-mode is multiple.
default-valueT | T[]Initial selection when uncontrolled.
selection-mode"none" | "single" | "multiple""none"Whether tags can be selected.
disallow-empty-selectionbooleanfalsePrevent the user from deselecting the last selected tag.
escape-key-behavior"clearSelection" | "none""clearSelection"What the Escape key does.
colorTagGroupColorDefault color of the tags.
variant"soft" | "solid" | "outline" | "modern"Default variant of the tags.
size"sm" | "md" | "lg"Default size of the tags.
shape"pill" | "rounded"Default shape of the tags.
bystring | ((a: T, b: T) => boolean)Property name or comparator used to compare object values.
loopbooleantrueWrap keyboard navigation from the last tag to the first and vice versa.
disabledbooleanPrevents interaction with the group and all of its tags.
dir"ltr" | "rtl"Reading direction.
aria-labelstringAccessible name of the group. Required unless aria-labelledby is used.

The group emits update:modelValue and remove. The slot receives modelValue.

TagGroupItem

PropTypeDefaultDescription
valueTThe unique value of the tag. Required.
colorTagGroupColorgroup, then "gray"Color of the tag.
variantTagGroupVariantgroup, then "soft"Variant of the tag.
sizeTagGroupSizegroup, then "md"Size of the tag.
shapeTagGroupShapegroup, then "pill"Shape of the tag.
iconstringIcon shown before the text.
trailing-iconstringIcon shown after the text.
dotbooleanfalseShow a colored dot before the text.
avatarstringImage shown before the text.
removablebooleanfalseShow the remove button. The group must listen to @remove.
delete-iconstring"lucide:x"Icon of the remove button.
show-checkbooleantrueReplace the leading content with a check mark while selected.
disabledbooleanPrevents interaction with the tag.
text-valuestringPlain text used for typeahead and the accessible name. Defaults to the text of the tag.

The leading content is chosen in this order: check mark (when selected), dot, avatar, icon. The modern variant shows a dot by default, unless an avatar or icon is set.

SlotPropsDescription
default{ selected, disabled }The text of the tag. Defaults to the value.
leading{ selected, disabled }Content before the text.
trailing{ selected, disabled }Content after the text.
delete{ selected, disabled }Replaces the remove button. Only rendered when removable.

TagGroupItemDelete

PropTypeDefaultDescription
iconstring"lucide:x"Icon shown inside the button.
aria-labelstring"Remove"Override to translate the accessible name. The tag name is appended.

Accessibility

The group has the grid role (or group while it is empty) and every tag is a row. Focus moves with a roving tabindex, so the whole group is a single tab stop. Selected tags set aria-selected, and additions to the group are announced politely while it has focus.

KeyDescription
TabMoves focus into the group, then to the remove button of the focused tag, then out.
ArrowRight / ArrowDownMoves to the next tag.
ArrowLeft / ArrowUpMoves to the previous tag.
Home / EndMoves to the first or last tag.
Space / EnterToggles the focused tag when the group is selectable.
Delete / BackspaceRemoves the focused tag, or all selected tags if it is selected. Needs @remove.
EscapeClears the selection.
Any characterMoves to the next tag that starts with the typed text.