Skip to content

TagInput

Free-text tagging with removable chips. Enter or comma adds a tag (trimmed, deduped case-insensitively, capped by max), Backspace on an empty box removes the last tag, and one hidden input per tag carries the form name for native submit.

Example

  • HTML
  • CSS

Press Enter or comma to add a tag.

<TagInput
  id="skills"
  label="Skills"
  name="skills"
  values={["HTML", "CSS"]}
  hint="Press Enter or comma to add a tag."
/>

Max tags

  • Vite
<TagInput
  id="topics"
  label="Topics"
  name="topics"
  values={["Vite"]}
  max={3}
  placeholder="Up to 3 topics"
/>

Error state

  • draft

Pick at least one published label.

<TagInput
  id="labels"
  label="Labels"
  name="labels"
  values={["draft"]}
  error="Pick at least one published label."
/>

Props

PropTypeDefaultDescription
idstring-Required. Input id; Field label targets it.
labelstring-Visible label; also names the chip list.
namestringidHidden-input form name; one input per tag.
valuesstring[][]Initial tags, rendered as chips.
placeholderstring"Add a tag"Text-box placeholder.
maxnumber-Maximum tag count; extra adds are ignored.
hintstring-Help text below the input.
errorstring-Error message; sets aria-invalid.
requiredbooleanfalseMarks the label required.
disabledbooleanfalseNon-interactive; disables box and chip buttons.
classstring-Style passthrough.

Accessibility