Skip to content

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
  • design

Press Enter or comma to add.1/8

Basic

Enter or comma adds; Backspace at the start selects the last tag, a second Backspace removes it. Try pasting “glass, motion; a11y”.

  • design
  • motion

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.ts
  • lib/{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.

  • React
  • TypeScript

2/6

Value: ["React","TypeScript"]

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

    Props

    PropTypeDefaultDescription
    onBlurFocusEventHandler<HTMLElement>NoneCalled when focus leaves the control (not when it moves between the control's own parts).
    namestringNoneSubmits one hidden input per tag with a form.
    requiredbooleanNoneMarks the field as required.
    disabledbooleanfalseDisables typing and removing tags.
    aria-invalidboolean | "true" | "false"NoneMarks the field as invalid (also set automatically when error is shown).
    aria-describedbystringNoneIds of elements that describe the field, merged with the control's own description and error ids.
    valuestring[]NoneSets the current list of tags when controlled.
    defaultValuestring[][]Sets the starting tags when uncontrolled.
    onValueChange((tags: string[]) => void)NoneCalled with the new list whenever a tag is added or removed.
    labelReactNodeNoneText above the field, linked to the input as its accessible name.
    descriptionReactNodeNoneMuted helper text under the field.
    errorReactNodeNoneError message from outside (e.g. form validation). Overrides the built-in messages.
    placeholderstring"Add a tag…"Hint shown while the field is empty.
    placeholderMorestring"Add more…"Placeholder once at least one tag exists.
    maxnumberNoneMaximum number of tags a person can add.
    maxLengthnumberNoneSets the maximum number of characters in one tag.
    allowDuplicatesbooleanfalseAllow the same tag twice. Duplicates compare case-insensitively unless caseSensitive.
    caseSensitivebooleanfalseMakes "Tag" and "tag" count as different tags.
    delimitersstring[][","]Keys that add a tag, besides Enter.
    pasteSplitRegExpcommas, semicolons, tabs, new lines and your delimitersSplits pasted text into tags.
    transform((tag: string) => string)defaultTransformClean a tag before it is added.
    validate((tag: string, tags: string[]) => string | null | undefined | void)NoneYour own rule: return an error message to reject the tag.
    addOnBlurbooleanfalseAdd what's typed when the field loses focus.
    suggestionsTagSuggestion[][]Lists suggestions under the field while typing.
    restrictToSuggestionsbooleanfalseWith suggestions: only tags from the list can be added.
    clearablebooleantrueShow the × button that removes every tag.
    readOnlybooleanfalseShow the tags but do not allow changes.
    idstringNoneid of the text input (so a <label htmlFor> can point at it).
    sizeFieldSize"md"Height, consistent across every form control: "sm" 32px, "md" 40px, "lg" 48px (sm and md are 44px on touch screens), the same scale as Button.
    aria-labelstringNoneAccessible name when there is no visible label.
    labelsPartial<TagsInputLabels>defaultTagsInputLabelsEvery other string, for translation: labels={{ tagsLabel: "…" }}; omitted keys keep the English of defaultTagsInputLabels. All 14 keys of TagsInputLabels are listed in the key table under the props table.
    classNamestringNoneClass for the outer wrapper (label + field + helper text).
    inputClassNamestringNoneAdds extra classes to the text input.
    TagsInputLabels keys and English defaults (14)
    Pass any key in labels; the rest keep the defaults of defaultTagsInputLabels.
    KeyEnglish default
    tagsLabelTags
    remove(tag) => `Remove ${tag}`
    clearAllRemove all tags
    hintPress Enter or comma to add a tag. Backspace at the start selects the last tag.
    tagHintPress Backspace or Delete to remove
    duplicate(tag) => `“${tag}” is already added.`
    maxReached(max) => `You can add up to ${max} tags.`
    tooLong(max) => `Tags can be at most ${max} characters.`
    notAllowed(tag) => `“${tag}” isn’t in the list.`
    added(tags) => (tags.length === 1 ? `Added ${tags[0]}` : `Added ${tags.length} tags`)
    removed(tag) => `Removed ${tag}`
    clearedAll tags removed
    skipped(count, reason) => `${count} not added. ${reason}`
    count(count, max) => `${count}/${max}`

    Keyboard

    KeysAction
    Enter/,Add what you typed (or the highlighted suggestion).
    BackspaceAt the start of the field, select the last tag; press again to remove it.
    Arrow Left/Arrow RightFrom the start of the field, walk the tags (flipped in right-to-left pages).
    Backspace/Deleteon a tagRemove it; focus moves to the neighboring tag.
    Any letteron a tagJump back to the field and type.
    Paste"a, b; c" (or one per line) adds several tags.

    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

    67 components pages in all: browse them on All components.

    By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .