Componentpickers2.92 KB gzipZero dependencies
Tag Input
Tag input with pill chip badges, remove buttons, backspace deletion, and dashed container.
Preview
Live Preview
Installation
Tokens guide →Add to your project via CLI (zero dependencies, code you own):
npx bigbullui add tag-inputOr install the full npm package:
npm install bigbulluiUsage
tsx7 lines
import { TagInput } from "@/components/ui/tag-input"; <TagInput defaultValue={["VIP PASS", "INDIE ROCK", "MAIN STAGE"]} suggestions={["BACKSTAGE", "EARLY BIRD", "FESTIVAL"]} onChange={(tags) => console.log(tags)}/>Source code
tag-input.tsx + 1 helperZero third-party dependencies (2 local files shown in tabs below).
tsxtag-input.tsx483 lines
"use client"; import * as React from "react";import { cn, escapeRegExp } from "./lib/utils"; export interface TagInputProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "onChange" | "defaultValue"> { /** Controlled array of tag strings */ value?: string[]; /** Default array of tag strings for uncontrolled mode */ defaultValue?: string[]; /** Callback fired when tags array changes */ onChange?: (tags: string[]) => void; /** Input placeholder text when empty */ placeholder?: string; /** Maximum number of allowable tags */ maxTags?: number; /** Whether duplicate tags are allowed (default: false) */Props
Interactive Prop Playground
Tweak parsed AST props below to generate ready-to-paste JSX.
tsx3 lines
import { TagInput } from "@/components/ui/tag-input"; <TagInput />| Prop | Type | Description |
|---|---|---|
| value | string[] | Controlled array of tag strings |
| defaultValue | string[] | Default array of tag strings for uncontrolled mode |
| onChange | (tags: string[]) => void | Callback fired when tags array changes |
| placeholder | string | Input placeholder text when empty |
| maxTags | number | Maximum number of allowable tags |
| allowDuplicates | boolean | Whether duplicate tags are allowed (default: false) |
| suggestions | string[] | List of suggested tags rendered as quick clickable stubs |
| label | string | Micro header label (default: "TICKET CATEGORIES & GENRES") |
| serial | string | Ticket stub serial identifier (default: "TAG-STUB #902") |
| disabled | boolean | Whether the input is disabled |
| notched | boolean | Whether to render ticket punch notches on side borders (default: true) |
| tagVariant | "default" | "accent" | "secondary" | "outline" | Visual chip variant style |
| addOnBlur | boolean | Whether to automatically add tag when input loses focus (default: true) |
| delimiter | string | Custom delimiter to split pasted text or typed text (default: ",") |
| enableSound | boolean | Whether to play mechanical ticket punch click sound via Web Audio API (default: true) |
| onTagClick | (tag: string) => void | Callback fired when a tag is clicked |
| onTagRemove | (tag: string, index: number) => void | Callback fired when a tag is removed |
| className | string | Additional CSS class names |