Skip to content

shadcn.io is not affiliated with official shadcn/ui

Shadcn Tags Input for React Radix UI

Allows users to add tags to an input field.

Framework
UI library

Radix UI does not include this primitive, so this page uses the Ark UI component. The visuals match the Ark UI version.

React
Solid
Vue
Svelte

Installation

bunx --bun shadcn@latest add https://kit.dev/r/radix/tags-input.json

Anatomy

TagsInputContext
├── TagsInputLabel
├── TagsInput
├── TagsInputInput
├── TagsInputClearTrigger
└── TagsInputItem
    ├── TagsInputItemPreview
    ├── TagsInputItemInput
    ├── TagsInputItemText
    └── TagsInputItemDeleteTrigger

Usage

import { Field, FieldLabel } from "@/components/ui/field";
import {
  TagsInput,
  TagsInputContext,
  TagsInputItem,
} from "@/components/ui/tags-input";
const defaultValue = ["React", "Solid", "Vue", "Svelte"];

const TagsInputDemo = () => (
  <Field className="w-full max-w-sm">
    <FieldLabel>Frameworks</FieldLabel>
    <TagsInput className="w-full" defaultValue={defaultValue}>
      <TagsInputContext>
        {({ value }) =>
          value.map((value, index) => (
            <TagsInputItem index={index} key={value} value={value}>
              {value}
            </TagsInputItem>
          ))
        }
      </TagsInputContext>
    </TagsInput>
  </Field>
);

Accessibility

KeyDescription
ArrowDown
Move down.
ArrowLeft
Move left.
ArrowRight
Move right.
Escape
Dismiss.
Backspace
Delete backward.
Delete
Delete.
Enter
Activate the focused item.
Space
Activate the focused control.

Demos

Blur Behavior

Combobox

Controlled

Controlled Input Value

Custom Delimiter

Disable Editing

Disabled

Field

Invalid

Max Length

Max Tags

Max With Overflow

Paste Behavior

Sanitize Value

Size Lg

Size Md

Size Sm

Validation

API Reference

TagsInput

div

PropType
AttributeType

TagsInputControl

div

PropType
AttributeType

TagsInputInput

input

PropType
className?string
AttributeType

TagsInputClearTrigger

button

PropType
AttributeType

TagsInputItem

div

PropType
valuestring
disabled?boolean
AttributeType

TagsInputItemPreview

div

PropType
AttributeType

TagsInputItemInput

input

PropType
className?string
AttributeType

TagsInputItemText

span

PropType
AttributeType

TagsInputItemDeleteTrigger

button

PropType
AttributeType
CSS variableType
--radiusstring

TagsInputRootProvider

div

PropType
valueUseTagsInputReturn
AttributeType

useTagsInput

PropType

TagsInputContext

PropType