Components
Tag Input
Type and press Enter to add tags.
<TagInput label="Skills" defaultValue={["React", "TypeScript"]} />Installation
npx shadcn@latest add https://ui.zjkm.tech/r/tag-input.jsonimport { TagInput } from "@/components/tag-input"Using JavaScript? Set tsx: false in components.json and the CLI converts it.
New to shadcn? Run npx shadcn@latest init first. The CLI needs components.json and the @/ import alias.
Usage
Type and press Enter or comma to add a tag. Backspace in the empty field removes the last one, and each tag has its own remove button. Duplicates are skipped.
import { TagInput } from "@/components/tag-input";
export function Skills() {
return <TagInput label="Skills" defaultValue={["React"]} onChange={(tags) => console.log(tags)} />;
}Props
| Prop | Type | Default | Description |
|---|---|---|---|
label | string | The label. | |
defaultValue | string[] | [] | Tags to start with. |
onChange | (tags: string[]) => void | Called with every change. | |
placeholder | string | "Add a tag…" | Placeholder in the field. |
className | string | Classes for the wrapper. |
With reduced motion, new tags appear without popping in.