Skip to content
GitHub (opens in a new tab)

TagInput

Tags the person types; Enter or a delimiter adds one.

stableMoleculecontracts/taginput.json

Preview

TagInput

Tags the person types. Enter or a comma adds one. Suggestions and a maximum are optional. A fixed list is MultiSelect.

Master

A duplicate is not added and says so. The first Backspace on an empty query highlights the last tag; the second removes it.

billing

Usage

Wrap with Field. Each tag is kit Tag. Use MultiSelect when every value must come from a list.

Do's

  • Free-form labels such as keywords the person creates
  • A short list of suggestions while they type, without a fixed option set

Don'ts

<Field label="Keywords" htmlFor="keywords"><TagInput id="keywords" /></Field>

Tags the person types. Enter or a delimiter adds one. Optional suggestions and an optional maximum with a visible count.

When to use

  • Free-form labels such as keywords the person creates
  • A short list of suggestions while they type, without a fixed option set

When not to use

  • Choosing from a fixed list — use MultiSelect
  • One value from a list — use Combobox or Select

What an agent reads

import { TagInput } from "agentic-ds-kit";
must
  • Escape closes only this panel, not a parent Modal, Drawer or AlertDialog
  • Input is role=combobox when suggestions are open
  • Enter or a delimiter adds the typed text. Arrow keys move through suggestions
  • Backspace on an empty query highlights the last tag and says 'Press Backspace to remove {tag}'; a second Backspace removes it. Any other key clears the highlight
  • A duplicate tag, compared case-insensitively, is not added; '{tag} is already added' is shown with an icon and announced (aria-live polite)
  • With maxTags, the count is in the input's aria-describedby ('3 of 8 tags'); an add past the limit is announced, not silently dropped
  • Escape closes suggestions. Each tag remove button removes that tag
  • Must have a Field label or ariaLabel
  • built-in labels (suggestions, tagExists, tagLimit, tagCount, removeTagHint) come from KitLabelsProvider; English by default
defaults
  • size md
  • placeholder Add a tag
  • disabled false
  • error false
  • delimiters [","]
stops if
  • Do not use TagInput to choose from a required option list — use MultiSelect
  • Do not invent a local chip — tags are kit Tag
  • Do not use raw hex

From contracts/taginput.json: must is the a11y requirements, defaults the prop defaults, stops if the doNot rules where the agent asks instead of inventing a cousin.

Props

NameTypeRequiredDefaultNotes
idstringYes——
sizelg | md | smNomdSame 32 / 36 / 40 frame as Input and Button. lg uses md tags.
valuestring[]No——
defaultValuestring[]No——
onChangefunctionNo—(value: string[]) => void
placeholderstringNoAdd a tag—
disabledbooleanNofalse—
errorbooleanNofalse—
suggestionsstring[]No—Shown while typing. Picking one adds a tag.
delimitersstring[]No[","]Single-character keys that commit a tag, besides Enter.
maxTagsnumberNo—Most tags allowed. Shows a count such as 3/8 at the end of the field. Adds past it are blocked with a message.
namestringNo——
ariaLabelstringNo——
describedBystringNo——
  • Component
    →

    MultiSelect

    Choose several values.

  • Component
    →

    Combobox

    Type to filter one value, including a list the parent loads asynchronously.

  • Component
    →

    Select

    Choose one or several options from a list.