Skip to content
UI

Search docs

Search components and documentation

New
Menu

Tags Input

Free-form multi-value input rendered as removable chips — add with Enter or comma, remove with Backspace or the chip's close button.

reacttailwind

Press Enter or comma to add, Backspace to remove.

Installation

npx logic2b@latest add tags-input

Usage

import { TagsInput } from "@/components/ui/tags-input"

const [tags, setTags] = React.useState<string[]>([])

<TagsInput
  value={tags}
  onValueChange={setTags}
  placeholder="Add a tag…"
/>

Enter or comma commits the draft, pasted comma-separated text is split into tags, Backspace on an empty field removes the last tag, and blur commits whatever is pending. Duplicates are ignored.

API

Prop Type Default
value / defaultValue string[] — controlled/uncontrolled tag list []
onValueChange (value: string[]) => void
placeholder string — hint shown in the free-text field
max number — cap the list; the field locks at the limit
disabled boolean false
id / aria-label / aria-labelledby forwarded to the inner text field for labeling

Examples

Max tags

Cap the list with max — extra pasted values are dropped and the field disables until a tag is removed.

design

1/3 — the field locks when the limit is reached.

Accessibility

  • The editable part is a real <input>: label it with <Label htmlFor> (the id is forwarded) or aria-label.
  • Each chip’s close button exposes aria-label="Remove <tag>".
  • Backspace on an empty field removes the last tag, so the whole control works without a pointer.