reacttailwind
Press Enter or comma to add. Up to 6 topics.
Installation
$ pnpm dlx shadcn@latest add @synccn/tag-inputFirst time in this project? Connect synccn with one command.
Usage
import { TagInput } from "@/components/ui/tag-input";<TagInput suggestions={topics} max={6} />API reference
Generated from the component's TypeScript types, so it always matches the code.
TagInput
Type and press Enter or comma to add a tag. Backspace removes the last one.
PropTypeDescription
- value
string[]Controlled tags.
- defaultValue
string[]Default
[]Initial tags when uncontrolled.
- onValueChange
(tags: string[]) => voidCalled with the new tags.
- placeholder
stringDefault
"Add a tag…"Shown when empty.
- max
numberMost tags allowed.
- suggestions
string[]Default
[]Offered as the user types.
- className
stringExtra classes for the root element.
Dependencies
Read from the component's imports when the site builds. The CLI installs all of these for you.
npm packages
- clsx for cn()
- tailwind-merge for cn()
- lucide-react for X
Keyboard
- Enteror,Add the typed tag
- BackspaceRemove the last tag when the field is empty
Accessibility
- Each tag has a remove button with an accessible label.
From the source
Read from this component's code when the site builds, so it can't drift.
- ARIA attributes: aria-label
- Keys handled: Enter, Backspace
More inputs
ButtonSeven variants, four sizes and a built-in loading state.InputText field with optional leading icon and invalid state.TextareaMulti-line field that grows with its content and counts characters.CheckboxChecked, unchecked and indeterminate, with label and description.SwitchToggle with a springy thumb in three sizes.Radio GroupPick one option, shown as dots or as selectable cards.