Tags input
A field for free-text tags: labels, keywords, email recipients. Anything can be typed and becomes a tag. When the tags must come from a known list, use the multi-select instead.
Install
npx shadcn@latest add @thrum-pro/tags-inputThis is a Pro component. The command works once your project has a licence key: set up Pro or see pricing.
Data shape
type Tags = string[];const tags = [
"billing",
"onboarding",
"q4-launch",
];Props
| Prop | Type | Default | Description |
|---|---|---|---|
value | readonly string[] | – | The tags, when the parent holds them. Use it with onValueChange. |
defaultValue | readonly string[] | Default [] | The tags at first, when the field holds them itself. |
onValueChange | (tags: string[]) => void | – | Called with the whole new list when tags are added or one is removed. |
max | number | – | The most tags the field takes. Past it, new text stays in the field and the message says Up to 5 tags. |
validate | string | – | A regular expression, as text, that every tag must match from start to end. A tag that does not match stays in the field to be fixed. |
invalidMessage | string | Default '“{tag}” does not match the format' | What to say when a tag does not match validate. {tag} is replaced by the tag. |
size | "sm" | "md" | "lg" | Default "md" | 28, 32 or 40 pixels tall. The field grows a row at a time as the tags wrap. |
sound | boolean | Default true | Play a soft sound when tags are added and when one is removed, if the visitor has sound on. |
name | string | – | The form field name. Each tag is sent as its own value under it. |
disabled | boolean | Default false | Dimmed; nothing can be typed or removed. |
readOnly | boolean | Default false | The tags show without remove buttons, and nothing can be added. |
placeholder | string | – | Shown while there are no tags. |
className | string | – | Classes for the root element. The field fills its width. |
…input props | ComponentProps<"input"> | – | id, aria-label and the rest go to the text input. |
Motion and sound
Motion
- Newly added tags fade and scale in from 92% over 150 ms; removed tags leave in one frame so remaining tags settle immediately.
- The remove buttons and the field's border change colour over 150 ms. Reduced motion: every change happens at once.
Sound
- A soft rising sound when tags are added, once per Enter, comma or paste however many tags it adds.
- A soft falling sound when a tag is removed.
Sound is off until the visitor turns it on. Pass sound={false} to keep this component silent. How sound works
Accessibility
- The text field takes its name from a label element or an aria-label.
- Each tag has a remove button named Remove and the tag's text.
- A refused tag is explained in a polite live region linked to the field: already added, does not match, or the limit.
- A pasted list is split at commas and line breaks; each piece is checked on its own.
- A long tag is cut with an ellipsis and keeps its full text in a tooltip. The field wraps tags onto new rows at 160 pixels wide.
| Keys | Action |
|---|---|
| Enter / , | Turn the typed text into a tag. Enter in an empty field is left to the form. |
| Backspace | In the empty field: select the last tag. On a tag: remove it and return to the field. |
| Delete | On a tag: remove it. |
| ← / → | From the start of the field, move onto the tags, then between them. Past the last tag, back to the field. |
| Home / End | On a tag: go to the first tag, or back to the field. |
Source
The source comes with Pro
TypeScript source · Copy-paste ready · MIT-compatible for client projects · Includes all dependencies
Files and dependencies
- Adds
components/ui/tags-input.tsx- Packages
- None
- Brings along
- Sound engineTag
Changelog
- 1.0.0 · 2026-12-03First release.