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-input

Usage

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.

PropTypeDefault
value

Controlled tags.

string[]—
defaultValue

Initial tags when uncontrolled.

string[][]
onValueChange

Called when tags are added or removed.

(tags: string[]) => void—
max

Maximum number of tags.

numberInfinity
validate

Return false or an error message to refuse a tag.

(tag: string) => string | boolean | undefined—
onReject

Called when a tag is refused.

(tag: string, reason: string) => void—
separators

Keys 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.