Skip to content
ProLifetime access for $199, paid once, every future release included
Truffle UI

Tag Input

ProNew

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

PropTypeDefault
valuestring[]—
defaultValuestring[][]
onValueChange(tags: string[]) => void—
validate(tag: string) => string | undefined

Return a message to reject a tag, e.g. for an invalid email address.

—
maxnumber

The most tags the field accepts.

—
nounstring

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