Xzero UI
Pro library

Tag input

Turn short text values into removable tags.

$ pnpm dlx shadcn@4.23.0 add @xzero-ui/tag-input
Live · keyboard ready

When to use

When not to use

Installation

Register both Xzero UI namespaces in your project's components.json:

{
  "registries": {
    "@xzero-ui": "https://mcp.xzero.co.uk/r/{name}.json",
    "@xzero-ui-pro": "https://mcp.xzero.co.uk/r/pro/{name}.json"
  }
}
npx shadcn@4.23.0 add @xzero-ui/tag-input

Install xzero-foundation once, and import @/components/xzero/foundation.css in your app root. No Xzero token is used by this snapshot. For sample portraits, photos, fonts, or logos, download https://mcp.xzero.co.uk/install-assets.mjs and run node xzero-install-assets.mjs <receiving-project>.

Usage

import { TagInput } from "@/components/xzero/tag-input/tag-input";

export function TopicsField() {
  const [topics, setTopics] = useState(["design", "motion"]);
  return (
    <TagInput
      label="Topics"
      value={topics}
      onValueChange={setTopics}
      description="Press Enter or comma to add."
    />
  );
}

API reference

TagInput

A field that turns typed text into removable tags, with keyboard picking and a gliding selection ring.

PropTypeDefaultDescription
label (required)string–Visible label tied to the text input.
valuestring[]–Controlled tags.
defaultValuestring[][]Initial tags when uncontrolled.
onValueChange(value: string[]) => void–Called with the full list after each add or remove.
placeholderstring"Add a tag"Shown while there are no tags.
descriptionstring–Helper copy under the field.
idstring–Input id. Generated when omitted.

Keyboard interactions

KeysAction
Enter / ,Adds the typed text as a tag. Duplicates (case-insensitive) pulse the existing tag instead.
BackspaceAt the start of the input, picks the last tag; pressed again, removes the picked tag.
DeleteRemoves the picked tag.
ArrowLeft / ArrowRightMoves the pick between tags and back to the input.
EscapeClears the pick.

Accessibility

Motion

Responsive behavior

Performance

Notes for AI

Also in special inputs

Guidance for AI tools

Tag input: Turn short text values into removable tags. Follow the declared prop types and do not invent props. Keep keyboard access, reduced motion support, and both light and dark themes intact when adapting it.

Full library index: https://ui.xzero.co.uk/llms.txt

Browse all components