Mark Yo

Tag Input

Forms

About

Chip field where Enter, comma or Tab adds a tag that springs in while the rest glide aside via shared layout, with Backspace-twice removal, arrow-key chip navigation, a filtered keyboard-navigable suggestion combobox, max tags, duplicate prevention and a shake on validation rejection; controlled/uncontrolled, reduced-motion safe.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Tag Input to your project and fits it to your theme.

Code

How Tag Input is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

"use client"

import { useState } from "react"
import { TagInput } from "@/components/ui/karaui-tag-input"

const TOPICS = [
  "React",
  "Next.js",
  "TypeScript",
  "Tailwind CSS",
  "Motion",
  "Accessibility",
  "Design systems",
  "Animation",
  "Server components",
  "Testing",
];

const EMAIL = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;

export function TagInputPreview() {
  const [topics, setTopics] = useState(["React", "Motion"]);

  return (
    <div className="flex w-full max-w-md flex-col gap-6">
      <TagInput
        label="Topics"
        value={topics}
        onChange={setTopics}
        suggestions={TOPICS}
        maxTags={5}
        placeholder="Add a topic…"
        hint="Enter, comma or Tab to add · Backspace twice to remove"
      />
      <TagInput
        label="Invite by email"
        defaultValue={["ada@example.com"]}
        placeholder="name@company.com"
        validate={(tag) => EMAIL.test(tag) || "That doesn't look like an email"}
        hint="Paste a comma-separated list to add several"
      />
    </div>
  );
}

export default TagInputPreview

Dependencies

More by Mark Yo

View all
  • Loader

    Loader

    73
  • Pricing Table

    Pricing Table

    33
  • Approval Queue

    Approval Queue

    24
  • Bento Grid

    Bento Grid

    22
  • Expandable Tabs

    Expandable Tabs

    19
  • Image Gallery

    Image Gallery

    17
  • Wallet Card

    Wallet Card

    16
  • Donut Chart

    Donut Chart

    14

More in Forms

View all
  • Form

    Form

    7
  • Login 2

    Login 2

    16
  • Contact Form

    Contact Form

    33
  • Contact Card

    Contact Card

    1.1K
  • Book A Demo 1

    Book A Demo 1

    95
  • Premium Auth

    Premium Auth

    613
  • Onboarding Stepper

    Onboarding Stepper

    13
  • Authentication Card

    Authentication Card

    52