Tag Input
Turn typing into tags. They spring in, reflow smoothly, and Backspace asks twice before deleting.
Inputs
design-systemreactmotion
Enter or comma to add, Backspace twice to remove. Paste a comma separated list to add many at once.
Playground
Tweak the props, the preview and the code follow.
reactmotion
Props
6
<TagInput
defaultValue={["react", "motion"]}
max={6}
placeholder="Add
a
tag…"
/>Installation
npx @plumsydev/plum-ui add tag-inputUsage
import { TagInput } from "@/components/ui/tag-input"<TagInput defaultValue={["react"]} placeholder="Add a tag…" />Examples
Validation
validate rejects bad entries, max caps the count and onReject reports why.
lea@acme.com
1 / 5 seats used
Suggestions
Controlled value plus a list of quick picks.
bug
API Reference
TagInput
Extends the native input for everything but value, defaultValue and onChange.
| Prop | Type | Default |
|---|---|---|
valueControlled tags. | string[] | — |
defaultValueInitial tags when uncontrolled. | string[] | [] |
onValueChangeCalled when tags are added or removed. | (tags: string[]) => void | — |
maxMaximum number of tags. | number | Infinity |
validateReturn false or an error message to refuse a tag. | (tag: string) => string | boolean | undefined | — |
onRejectCalled when a tag is refused. | (tag: string, reason: string) => void | — |
separatorsKeys that commit the current text. | string[] | ["Enter", ","] |
Notes
- Duplicates aren't added: the existing tag flashes instead.
- Pasting text containing commas, tabs or new lines adds every part at once.