React Tags Input
A glass React tags input that turns typed text into chips, adds a pasted list at once and lets you walk and remove chips from the keyboard.
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/tags-input.json- designPress Backspace or Delete to remove
Press Enter or comma to add.1/8
Press Enter or comma to add a tag. Backspace at the start selects the last tag.TagsInputdefaultTagsInputLabels
Using it in a form? See the react-hook-form and zod recipe.
Basic
Enter or comma adds; Backspace at the start selects the last tag, a second Backspace removes it. Try pasting “glass, motion; a11y”.
- designPress Backspace or Delete to remove
- motionPress Backspace or Delete to remove
Press Enter or comma to add.
Press Enter or comma to add a tag. Backspace at the start selects the last tag.import { TagsInput } from "@/components/sheenui/tags-input/tags-input";
// Package build (after the first npm release, or a packed tarball): import { TagsInput } from "@sheenui/theme";
export function Example() {
return (
<TagsInput
label="Topics"
defaultValue={["design", "motion"]}
placeholder="Add a topic…"
description="Press Enter or comma to add."
/>
);
}Files to copy
6 folders · 12 files · 4 packages
- From
theme/src/ components/tags-input/components/status-icons/hooks/{use-controllable.ts, use-direction.ts, use-latest.ts, use-media-query.ts, use-preferences.ts}motion/tokens.tslib/{cn.ts, field-size.ts, form.ts, ime.ts, popup-a11y.ts, warn-once.ts}styles/
- shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/tags-input.jsonRegistry item: tags-input. The styles need the Tailwind v4 glass UI setup.- Packages
pnpm add @base-ui/react clsx motion tailwind-merge
Suggestions and a limit
Suggestions open under the field while you type (or on click). Matching text is highlighted; the counter turns accent at the limit.
- ReactPress Backspace or Delete to remove
- TypeScriptPress Backspace or Delete to remove
2/6
Press Enter or comma to add a tag. Backspace at the start selects the last tag.Value: ["React","TypeScript"]
import { useState } from "react";
import { TagsInput } from "@/components/sheenui/tags-input/tags-input";
// Package build (after the first npm release, or a packed tarball): import { TagsInput } from "@sheenui/theme";
export function Example() {
const [skills, setSkills] = useState(["React", "TypeScript"]);
return (
<TagsInput
label="Skills"
value={skills}
onValueChange={setSkills}
suggestions={[{ value: "React", description: "UI library" }, "GraphQL", "Node.js", "PostgreSQL"]}
max={6}
placeholder="Search or add a skill…"
/>
);
}Validation
Your own rule plus built-ins: each address must be valid and unique, lower-cased on the way in. Paste a whole list: the bad ones are reported, the rest are added.
Separate addresses with commas, spaces or new lines.0/10
Press Enter or comma to add a tag. Backspace at the start selects the last tag.import { TagsInput } from "@/components/sheenui/tags-input/tags-input";
// Package build (after the first npm release, or a packed tarball): import { TagsInput } from "@sheenui/theme";
const EMAIL = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
export function Example() {
return (
<TagsInput
label="Invite by email"
placeholder="name@example.com"
delimiters={[",", " ", ";"]}
transform={(t) => t.trim().toLowerCase()}
validate={(t) => (EMAIL.test(t) ? null : `“${t}” isn’t an email address.`)}
max={10}
name="invites"
/>
);
}Props
Keyboard
Accessibility
- The field is a labeled input with a hidden keyboard hint; each tag has a name and a remove button ("Remove React").
- Added, removed and rejected tags (duplicate, too long, over max) are announced politely, and the error is linked to the field.
- During IME composition Enter confirms the text and never adds a tag.
All exports on this page
TagsInput— Tags input: type and press Enter (or a comma) to turn text into a chip.defaultTagsInputLabels— Default English strings of TagsInputLabels; spread it and override single keys to reword.
When to use the tags input
- Use it as a tag input component for a blog editor's keywords field where people type a word and press Enter or a comma to turn it into a chip, with max capping how many are allowed. Use it as a multi-value input in Tailwind projects when people add several short values, such as topics, and each becomes a removable tag.
- Use it for an email recipients or invite field where pasting a list such as a, b; c or one per line adds several tags at once through pasteSplit.
- Use it for labels on a task or file, where the optional suggestions prop opens a glass list under the field so people reuse existing tags instead of inventing near duplicates.
- Skip it when users must pick only from a fixed, known list; Combobox with multiple selection validates against it, and plain Input fits one free value such as a title.
- Pair it with its own label and error props for the name and message, Badge for how the saved tags display elsewhere, and Button to submit the list that name posts as hidden inputs.
Frequently asked questions
Related pages
67 components pages in all: browse them on All components.
By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .