UIComponentsReact
A text field that turns what is typed into tags, each a chip with a button that removes it.
Built on the headless Tags Input.See its API in Docs
Rendered by React 19.3.1
Installation
npx shadcn@4.23.0 add https://hamur.dev/r/react/tags-input.jsonIt also adds utils, button. The app needs its setup first: Installation.
Usage
Put a TagsInputList and a TagsInputInput inside TagsInput, and render one TagsInputTag per entry of the value inside the list, each holding a TagsInputTagContent with a TagsInputTagText and a TagsInputTagRemove. Add a TagsInputTagEditInput to the content to let a tag be edited in place under editable, and a TagsInputClear named with aria-label to remove every tag. Name the list with aria-label, or put the field in a Field whose label names it. Enter and the delimiters (a comma by default) add a tag; adding, refusing, removing, editing, the keyboard and the announcements come from the headless Tags Input.
import {
TagsInput,
TagsInputClear,
TagsInputInput,
TagsInputList,
TagsInputTag,
TagsInputTagContent,
TagsInputTagEditInput,
TagsInputTagRemove,
TagsInputTagText,
} from '@/components/ui/tags-input'Examples
Default
Three topics in the field's box, each with its remove button, and the input after them.
Editable
Tags edited in place with Enter, a refused duplicate, and a Clear at the box's end.
Rendered by React 19.3.1
The Root is the Input's box: it is ringed while the input has focus and turns destructive while an entry is refused or the field is invalid. A tag is a chip whose remove button is the Button's ghost icon-xs, 24 by 24 CSS pixels, so it meets the target size of WCAG 2.5.8. A disabled tag is dashed and unfilled rather than only greyed, and a focused tag rings its chip. While a tag is edited its text gives way to an input as wide as the text, in the same chip. This item takes Base UI's component ID as its slug and one name per Base UI part.
API reference
The styled parts pass every prop to the headless part they wrap and add classes. The props, data attributes and keyboard are on Tags Input's API reference.