Menu

Tag input

Field that collects tags. 3 states.

israt@shapla.example

Press Enter after each email.

Installation

$ npx uix-ui@latest add tag-input

This copies the file into components/ui/tag-input.tsx in your project. npx shadcn@latest add @uix/tag-input works too.

Usage

tag-input.tsx
import { TagInput } from "@/components/ui/tag-input";

<div style={{ width: 360, maxWidth: "100%" }}>
  <TagInput label="Invite the team" defaultValue={["israt@shapla.example"]} helper="Press Enter after each email." />
</div>

Props

PropTypeDefaultDescription
labelReact.ReactNode–
secondaryLabelReact.ReactNode–Right-aligned note next to the label, for example "Optional".
feedbackReact.ReactNode–Message under the field.
helperReact.ReactNode–Same as feedback.
errorstring–Error message; also marks the field invalid and replaces the feedback.
valuestring[]–The tags (controlled).
defaultValuestring[]–
onValueChange(tags: string[]) => void–
maxTagsnumber–Stops accepting tags at this count.

Everything else is passed to the root element, so className, aria-* and event handlers work as usual.

Dependencies

Installed for you by the CLI.

  • class-variance-authority
  • clsx
  • tailwind-merge
  • lib/utils.ts
  • components/ui/icons.tsx
esc

↑↓ to navigate · ↵ to select · esc to close