Componentpickers2.92 KB gzipZero dependencies

Tag Input

Tag input with pill chip badges, remove buttons, backspace deletion, and dashed container.

Preview

Live Preview
Open ↗

Installation

Tokens guide →

Add to your project via CLI (zero dependencies, code you own):

npx bigbullui add tag-input

Or install the full npm package:

npm install bigbullui

Usage

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 helper

Zero 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 />
PropTypeDescription
valuestring[]Controlled array of tag strings
defaultValuestring[]Default array of tag strings for uncontrolled mode
onChange(tags: string[]) => voidCallback fired when tags array changes
placeholderstringInput placeholder text when empty
maxTagsnumberMaximum number of allowable tags
allowDuplicatesbooleanWhether duplicate tags are allowed (default: false)
suggestionsstring[]List of suggested tags rendered as quick clickable stubs
labelstringMicro header label (default: "TICKET CATEGORIES & GENRES")
serialstringTicket stub serial identifier (default: "TAG-STUB #902")
disabledbooleanWhether the input is disabled
notchedbooleanWhether to render ticket punch notches on side borders (default: true)
tagVariant"default" | "accent" | "secondary" | "outline"Visual chip variant style
addOnBlurbooleanWhether to automatically add tag when input loses focus (default: true)
delimiterstringCustom delimiter to split pasted text or typed text (default: ",")
enableSoundbooleanWhether to play mechanical ticket punch click sound via Web Audio API (default: true)
onTagClick(tag: string) => voidCallback fired when a tag is clicked
onTagRemove(tag: string, index: number) => voidCallback fired when a tag is removed
classNamestringAdditional CSS class names