UI

Tags

A labelled input field that turns free-form text entries into removable pill tags with a gliding pick ring, duplicate detection, and optional inline editing.

import { TagInput } from '@uthereal/ui/tag-input'

Tag input playground

designfrontendmotion
Press Enter or comma to add a keyword.
Loading interactive preview…

Overview

TagInput renders a labelled text field that turns typed entries into removable pill tags on Zag's tags-input machine. Pressing Enter, typing the delimiter, or moving focus out of the field commits the trimmed draft as a tag. Pressing Backspace or the arrow keys from the start of the input picks an existing tag with a gliding accent ring before removing it.

Your application owns the tags array and external validation. TagInput enforces maxTags, maxLength, and duplicate rules inline, reports every change through onValueChange, and never opens browser validation bubbles.

CapabilityBehavior
Entry & delimiterEnter, typing delimiter (, by default), or blurring commits trimmed text; pasted text lands in the input as typed
Pick & removalBackspace, arrow keys, or clicking picks a tag with a gliding ring; Backspace, Delete, or the remove button deletes
Limits & repeatsCaps tag count (maxTags, up to 50) and length (maxLength, up to 200); rejects case-insensitive repeats by default
Inline editingSet editable to edit a tag via double-click or Enter when picked; Enter saves, Escape cancels, empty text deletes
Form submissionWith name, a hidden input submits the comma-space-joined tag list with native HTML forms; form reset restores defaults

Use TagInput for free-form keywords, labels, topics, or recipients. Use Text for single-line or multi-line prose, and use a select or multiselect when choices come from a fixed list.

Usage

'use client'
import { useState } from 'react'
import { TagInput } from '@uthereal/ui/tag-input'

export function KeywordTags() {
  const [tags, setTags] = useState(['design', 'frontend'])

  return (
    <TagInput
      label="Keywords"
      name="keywords"
      placeholder="Add a keyword"
      description="Press Enter or comma to add a keyword."
      value={tags}
      onValueChange={setTags}
    />
  )
}

Omit value for an uncontrolled field initialized from defaultValue. When name is set, a hidden <input> submits the tags with the surrounding form unless the field is disabled.

Examples

Limits, duplicates, and custom delimiters

Set maxTags and maxLength to bound entries. By default (allowDuplicates={false}), repeating a tag ignoring case ("Design" for "design") keeps the typed draft in the input, pulses the existing tag, and announces duplicateLabel. Change delimiter to another punctuation or space character (such as ;) when tags themselves contain commas.

designfrontend
Max 4 tags, 20 characters each; duplicates are rejected.
Austin, TXPortland, OR
Press Enter or ; to commit tags containing commas.

Inline editing and non-editable states

Set editable to let users double-click a tag or press Enter on a picked tag to edit it in place (Enter saves, Escape cancels, and saving an empty tag removes it). Set readOnly to keep tags focusable and submitted with a form without remove buttons, or set disabled to dim the control and remove it from the tab order.

triageneeds-reviewv2
Double-click a tag or press Enter when picked to edit.
read:projectswrite:deployments
Focusable and submitted with the form, but locked.
legacyq2-launch

API reference

These serializable arguments and defaults come directly from the component schema.

ArgumentType / defaultDescription
labelstringDefault: "Tags"Visible label and accessible name. Name the information asked for, in sentence case.
hideLabelbooleanDefault: falseHide the label visually when the context already names the field. It is still announced.
descriptionstring—Supporting text below the field, announced with it. Use it for format hints and constraints.
errorstring—Validation message from your application. Setting it marks the field invalid; the message is linked to the field and announced politely.
requiredbooleanDefault: falseMarks the field as required for assistive technology and shows an indicator. Your application validates the value.
readOnlybooleanDefault: falseThe value can be focused, selected, and copied, but not edited. It is still submitted with a form.
disabledbooleanDefault: falseUnavailable and removed from the tab order. A disabled field is not submitted with a form.
namestring—Native form field name, submitted with the value in a form.
placeholderstringDefault: "Add a tag"Text shown while there are no tags; defaults to "Add a tag". It rises back in when the last tag is removed. Never a substitute for the label.
defaultValuestring[]Default: []Initial tags, up to 50. Later argument edits do not reset an existing instance; use value and onValueChange to control it.
maxTagsintegerDefault: 50Most tags the user can add, up to 50. Further entries are ignored until a tag is removed.
maxLengthintegerDefault: 50Most characters in one tag, up to 200.
delimiterstringDefault: ","Typing this character adds the tag, like Enter. One punctuation or space character. As in Arc, pasted text lands in the field as typed text.
allowDuplicatesbooleanDefault: falseAccept a tag that is already in the list. By default a repeat is rejected ignoring case ("Design" repeats "design"): the existing tag pulses, the typed text stays, and duplicateLabel is announced.
editablebooleanDefault: falseLet the user edit a tag: pick it and press Enter, or double-click it. Enter saves, Escape cancels, and an emptied tag is removed. Off by default, as in Arc.
removeLabelstringDefault: "Remove {label}"Accessible name of each remove button. {label} is replaced with the tag, e.g. "Remove {label}".
duplicateLabelstringDefault: "{label} is already added"Announced politely when a repeated tag is rejected. {label} is replaced with the existing tag.
addedLabelstringDefault: "Added {label}"Announced politely when a tag is added, as in Arc ("Added {label}"). {label} is replaced with the tag.
removedLabelstringDefault: "Removed {label}"Announced politely when a tag is removed, as in Arc ("Removed {label}"). {label} is replaced with the tag.
selectedLabelstringDefault: "{label} selected. Press Backspace to remove it."Announced politely when Backspace, an arrow key or a click picks a tag, as in Arc. {label} is replaced with the tag.
variantoutline | soft | ghostDefault: "outline"Field surface: outline for forms, soft on busy surfaces, ghost for inline editing without a border.
sizesm | md | lgDefault: "md"Field height and text size: 32, 36, or 46 pixels. Matches the button and dropdown trigger of the same size.
recipestudio | softDefault: "studio"Visual treatment. Both recipes use the same interaction behavior.
themeTagInputTheme—Color mode, accent, and semantic tokens. See Theming for all keys and defaults.
motionnone | subtle | expressiveDefault: "subtle"Tags scale and blur in, glide aside and leave; the pick ring glides between tags; the shell height follows wrapped rows. Reduced motion keeps short fades; none makes every change immediate.
dirltr | rtl—Reading direction. Omit it to inherit the page direction.

React integration

PropPurpose
value, onValueChangeControlled string[] tag list. onValueChange fires on every add, edit, and removal in both modes
refRef to the native text <input> element.
presetApplication defaults (such as delimiter and localized announcement templates), overridden locally.
tokensCSS custom properties (--ui-*) applied after the typed theme on the field root.
renderIcon(name, context)Custom remove icon renderer; context provides size and slot ('remove'). Keep it decorative.
className, styleApplied to the root field element, which carries the resolved --ui-* tokens.
Native attributesForwarded to <input> (autoFocus, aria-*, data-*); keyboard and input events are managed.

The pure case-insensitive comparator sameTag(a, b) and tagSchema are also exported from @uthereal/ui/tag-input.

Keyboard & accessibility

KeyInteraction
TabMoves between each tag's remove button and the text input.
Enter, delimiterCommits the typed draft as a tag. When editable is enabled, Enter on a picked tag edits it.
BackspaceAt the start of the input, picks the last tag; pressing again removes the picked tag.
DeleteRemoves the currently picked tag and returns focus to the input.
ArrowLeft, ArrowRightFrom the start of the input, picks and moves across tags in reading order; past the end returns.
EscapeClears the current pick without modifying text, or cancels an active inline tag edit.
Enter (editing)Saves the edited tag text; saving an empty value deletes the tag.

The input is labelled by label (aria-labelledby) and described by description, error, and any consumer aria-describedby. required sets aria-required="true" while leaving validation to the host. Each tag's remove button is a native <button> tab stop named by removeLabel ("Remove {label}").

Additions, removals, picks, and rejected duplicates announce through a pre-mounted role="status" (aria-live="polite", aria-atomic="true") region using addedLabel, removedLabel, selectedLabel, and duplicateLabel. Each tag label sets unicode-bidi: plaintext so mixed-direction tags truncate cleanly. In dir="rtl", arrow navigation mirrors to reading order and the pick ring measures from the inline-start edge. forced-colors: active preserves tag borders, Highlight pick rings and edit edges, GrayText disabled tags, and Highlight focus outlines.

Motion and theming

  • Tags and caret: new tags scale in from 90% through a soft blur (motionTokens.blur.soft) on the morph spring while existing tags and the input caret glide to their updated slots; removed tags shrink to 90% and fade over 120ms.
  • Shell height: a ResizeObserver animates the shell height on the smooth spring as tags wrap onto new rows or collapse back.
  • Pick ring: picking a tag springs the accent ring in (snappy) and glides it between tags on the morph spring; clearing the pick fades and scales it out over 120ms.
  • Feedback: rejected duplicates pulse the existing tag to 1.06 (360ms), the placeholder rises back in when the last tag leaves, remove buttons press to 96% over 120ms and release on Arc's CSS spring, and field messages exit words over 120ms.
  • Reduced motion: prefers-reduced-motion: reduce disables scale, blur, layout glide, height springs, duplicate pulses, and press scales while keeping 120ms opacity crossfades. motion="none" makes every update immediate (0ms).

theme accepts the core and control token groups, plus borderStrong (hover shell edge) and accentSubtle (pick-ring fill). The shell rests on border, steps to borderStrong on hover, and turns ink on focus. An optional UtherealProvider supplies application-wide defaults.

Composition

TagInput is a leaf component. Its tag list (string[]) is host state at /fields/instance-<id>/value, initialized from defaultValue. Stored tags survive configuration edits to labels, limits, or appearance. See Building with agents.

{
  "type": "TagInput",
  "props": {
    "label": "Keywords",
    "placeholder": "Add a keyword",
    "defaultValue": ["design", "frontend"],
    "maxTags": 10
  },
  "children": []
}

On this page