Multi-value field whose typed text is pinched into a capsule chip, with two-step Backspace, cascading suggestions and recipients and stacked presets.
TypeType
Issue #418
Export fails on large files
Add a label…
Enter or comma to add · Backspace twice to remove
platform
q4
Inherited from the Platform project
StatusIn progress
tag-input · , lively
tag-input-demo.tsx
When to use
Use for a field holding several short typed values. Enter or comma makes a chip, Backspace removes in two steps, pasted lists are split, and reorderable chips can be dragged. Presets: inline, stacked, recipients.
When not to use
For picking one value from a fixed list use Combobox. For a single free value use Text Field.
Use it for a field that holds a list of short values typed by the person: labels, recipients, keywords,
allowed domains. For a fixed list of options to pick from, use a select or a combobox. For a single free
value, use a plain input.
The typed text is pinched into a chip in three beats. While you type, a faint capsule outline the size of
the future chip grows around the text (charge). On Enter or comma it fills, sinks and rounds into the
chip, and its close button pops in last (action). The row then reflows on one spring (settle).
Backspace on an empty input charges the last chip, and a second Backspace removes it.
value and onValueChange control the tags; inputValue and onInputValueChange control the pending
text (use them for async suggestions together with loading). Pass name to submit one hidden input per
tag, readable with FormData.getAll(name). Suggestions are plain strings or
{ value, label, description } objects.
Three layout presets share one look and one motion:
<TagInput preset="inline" /> {/* chips and input in one wrapping field (default) */}<TagInput preset="stacked" /> {/* one-line input, chips wrap in a row below it */}<TagInput preset="recipients" /> {/* "To" prefix, chip balls, two-line suggestions, ";" also commits */}
Set the character for the whole app with MotionKitProvider, or per field with temperament. At calm
the chips slide with no bounce and the sink is barely visible; the two-step Backspace stays.
The recipients preset adds a "To" prefix, an initial ball on each chip and suggestions with a name and a
second line. Pasted lists split on newlines, commas and semicolons, and each value commits in a cascade.
Use validate to reject values that are not addresses.
The stacked preset keeps the field at one line for long lists. A duplicate is rejected: the message rises
under the field, the typed text stays for correction, and the existing chip sinks once and releases to
point at it. max caps the list the same way.
TypeType
Moderation
Comments containing these keywords are held for review.
The chips are a role="list" labelled by the field's <label> (or named after noun.other). Each
chip is a role="listitem" that takes focus, with a remove button labelled Remove {tag}.
Give the input an accessible name: a <label htmlFor> pointing at its id, or aria-label.
With suggestions, the input is a role="combobox" with aria-expanded, aria-controls and
aria-activedescendant; the list is cmdk's listbox, aria-busy while loading.
A polite live region announces additions ("Added billing. 4 labels."), removals, the charged state
("Press Backspace again to remove billing.") and reorders. The error message is also linked with
aria-describedby and the input gets aria-invalid.
The charged state is announced and shown as a destructive fill with destructive-foreground text, so it
never relies on color alone. After a removal focus moves to the previous chip or the input, never to
body.
The pending outline, the recipients balls, the "To" prefix and the icons are aria-hidden.
Remove buttons are 24 px at md and lg; at sm the button is 20 px and reaches 24 px through its
hit area.
Focus shows a 3px ring on the field, and on a chip focused with the arrows. Colors come from your theme
(secondary, secondary-foreground, destructive, ring, border), so contrast follows it in light
and dark.
disabled sets aria-disabled on the group and removes the close buttons (their space is reserved so
chips keep their size). readOnly keeps chips visible and focusable without editing.
Commits the pending text, or the highlighted suggestion on Enter
Backspace (empty input)
First press charges the last chip; the second press removes it
Escape
Un-charges a charged chip and closes the suggestions
ArrowLeft (caret at start)
Moves focus to the last chip
ArrowLeft / ArrowRight (on chip)
Moves between chips; past the last chip returns to the input
Backspace / Delete (on a chip)
Removes the focused chip; focus goes to the previous chip or input
Alt + ArrowLeft / ArrowRight
Reorders the focused chip (reorderable only)
ArrowDown / ArrowUp
Opens the suggestions and moves the highlight pill
Tab
Leaves the field; the pending text is kept, not committed
Your onKeyDown runs first: if it calls event.preventDefault(), the component skips its own commit and
Backspace handling. onPaste, onFocus and onBlur are composed, never replaced.
With reduced motion (the OS setting, or MotionKitProvider reducedMotion="always") nothing disappears.
The pending outline resizes in a short fade, and a commit crossfades into the filled chip in place with no
sink or rounding. A charged chip only changes color, a removal is a fade instead of a shrink, and the
siblings move in the 120ms fade. The suggestion list's surface is opaque from its first frame and only
its rows fade. Chips keep their capsule shape, rim and fill at every frame.
Chip commit, charge and pop animate transform and opacity on motion values; the pending outline
width and the field height follow their content on a spring, so the field grows with the chips instead of
jumping. Layout is measured with a ResizeObserver on the field and the list, not on every frame.
While typing, the pending outline reserves the row the chip will need, so Enter causes no layout shift.
The suggestion list is mounted only while it is open. The highlight is one pill that moves along the
list. The loading spinner pauses off screen and in hidden tabs.
Dragging (reorderable) uses pointer capture on the chip and reorders live; there is no animation
loop at rest.
Technical sheet
Motion
calm
260 ms · bounce 0
lively
400 ms · bounce 0.3
playful
540 ms · bounce 0.45
Main spring of each temperament. Set it with the temperament prop or MotionKitProvider; the default is lively.
Size
Not measured yet · budget 15.0 kB gzip
Component and MotionKit helpers; excludes react, react-dom, @radix-ui/react-popover, motion.
Dependencies
@radix-ui/react-popover · peer
cmdk
motion · peer
Triggers
typing, press, keyboard focus, drag
Reduced motion
Chips crossfade in place without the sink or rounding, a charged chip only changes color, removals and the list fade, and siblings move in the 120ms fade.
Keyboard
Enter / , (delimiters)
Commits the pending text, or the highlighted suggestion on Enter
Backspace (empty input)
First press charges the last chip; the second press removes it
Escape
Un-charges a charged chip and closes the suggestions
ArrowLeft (caret at start)
Moves focus to the last chip
ArrowLeft / ArrowRight (on a chip)
Moves between chips; past the last chip returns to the input
Backspace / Delete (on a chip)
Removes the focused chip; focus goes to the previous chip or the input
Alt + ArrowLeft / ArrowRight
Reorders the focused chip (reorderable only)
ArrowDown / ArrowUp
Opens the suggestions and moves the highlight pill
Tab
Leaves the field; the pending text is kept, not committed
Browsers
Last 2 versions of Chrome, Edge, Firefox and Safari (iOS 16.4+)