Tag Input
ProNewFree-form chips: Enter, comma or a pasted list adds them, with validation, a limit and a shake for duplicates.
Installation
pnpm dlx shadcn@latest add @viewport/tag-input
First time? Add the @viewport registry to components.json. Setup takes one minute.
Usage
The code behind the preview above comes with Truffle Pro.
Props
| Prop | Type | Default |
|---|---|---|
| value | string[] | — |
| defaultValue | string[] | [] |
| onValueChange | (tags: string[]) => void | — |
| validate | (tag: string) => string | undefinedReturn a message to reject a tag, e.g. for an invalid email address. | — |
| max | numberThe most tags the field accepts. | — |
| noun | stringNames the kind of thing being entered, for announcements: "tag", "email", "label". | "tag" |
Accessibility
- Backspace selects the last chip and a second press removes it, with both steps announced.
- Rejected entries state the reason in text, not only in color.
- Pending text is committed when the field loses focus.
- Respects prefers-reduced-motion.