shadcn.io is not affiliated with official shadcn/ui
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.jsonAnatomy
TagsInputContext
├── TagsInputLabel
├── TagsInput
├── TagsInputInput
├── TagsInputClearTrigger
└── TagsInputItem
├── TagsInputItemPreview
├── TagsInputItemInput
├── TagsInputItemText
└── TagsInputItemDeleteTriggerUsage
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
| Key | Description |
|---|---|
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?stringAttributeType
TagsInputClearTrigger
button
PropType
AttributeType
TagsInputItem
div
PropType
valuestringdisabled?booleanAttributeType
TagsInputItemPreview
div
PropType
AttributeType
TagsInputItemInput
input
PropType
className?stringAttributeType
TagsInputItemText
span
PropType
AttributeType
TagsInputItemDeleteTrigger
button
PropType
AttributeType
CSS variableType
--radiusstringTagsInputRootProvider
div
PropType
valueUseTagsInputReturnAttributeType
useTagsInput
PropType
TagsInputContext
PropType