Skip to Content
zjkm-ui
Components

Tag Input

Type and press Enter to add tags.

  • React
  • TypeScript
Props
<TagInput label="Skills" defaultValue={["React", "TypeScript"]} />

Installation

npx shadcn@latest add https://ui.zjkm.tech/r/tag-input.json
import { 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

PropTypeDefaultDescription
labelstringThe label.
defaultValuestring[][]Tags to start with.
onChange(tags: string[]) => voidCalled with every change.
placeholderstring"Add a tag…"Placeholder in the field.
classNamestringClasses for the wrapper.

With reduced motion, new tags appear without popping in.

On this page