Skip to content
Logic2BUI

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@next 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.

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.

Live playground

Edit the component props and inspect the exact JSX before copying it. The preview loads only when this section enters the viewport.

Generated JSX
<TagsInput
  defaultValue={["registry", "accessible"]}
  placeholder="Add a tag…"
  max={5}
  aria-label="Component tags"
 />

API reference

Generated from the public TypeScript exports in src/ui/tags-input.tsx.

View JSON

TagsInput

Component

Tags input — free-form multi-value entry rendered as removable chips. Enter or comma commits the draft, paste splits on commas, Backspace on an empty draft removes the last tag. Duplicates are ignored; `max` caps the list.

Props: Omit<React.ComponentProps<"div">, "defaultValue" | "onChange"> & { value?: string[] defaultValue?: string[] onValueChange?: (value: string[]) => void placeholder?: string max?: number disabled?: boolean }
PropTypeRequiredDefaultDescription
valuestring[]No——
defaultValuestring[]No——
onValueChange(value: string[]) => voidNo——
placeholderstringNo——
maxnumberNo——
disabledbooleanNo——

Accessibility contract

Machine-readable behavior and consumer responsibilities for tags-input.

View JSON
Support
Authored behavior
Pattern
multi-value textbox
HTMLInputElement
Keyboard interactions for tags-input
KeysBehavior
Enter ,Commit the current text as a tag.
BackspaceRemove the last tag when the text field is empty.

Built-in semantics

  • The editable input receives id/aria-label/aria-labelledby; removal buttons name their tag.

Consumer responsibilities

  • Provide a visible label and announce additions/removals in application context when that feedback is important.