Docs
Tags Input
Tags Input

A flexible tag input component with multiple trigger keys, variants, and Zod validation support.

Add tags by pressing enter

Press backspace to remove the last tag

Overview

The Tags Input component enables efficient collection and management of multiple text values with an intuitive tagging interface, essential for categorization, keyword entry, and multi-value form fields. It supports various trigger keys (Enter, Space, Comma), configurable limits, and both default and pill variants with comprehensive validation. Perfect for skill tags, categories, search filters, and any scenario requiring organized multi-value input with excellent user experience.

Installation

pnpm dlx shadcn@latest add https://deltacomponents.dev/r/tags-input.json

Usage

"use client"
 
import { TagsInput } from "@/registry/inputs/tags-input"
 
export function Component() {
  return (
    <TagsInput
      label="Skills"
      name="skills"
      description="Add your technical skills"
      triggerKey="Enter"
      maxTags={10}
      onChange={(tags) => console.log("Tags:", tags)}
    />
  )
}

API Reference

Props

PropTypeDefaultDescription
labelstring-Label text for the input (required)
namestring-Form field name for submission (required)
descriptionstringundefinedDescription text below the label
hintstringundefinedHint text below the input
errorstringundefinedError message to display
requiredbooleanfalseWhether the field is required
pendingbooleanfalseWhether the field is in a loading state
defaultValuestring[][]Default tags array (uncontrolled)
valuestring[]undefinedControlled tags array
disabledbooleanfalseWhether the input is disabled
idstringnameID for the input element
variant"default" | "pill""default"Input styling variant
coloredBorderbooleanfalseShow colored border (pill variant only)
labelVariant"default" | "muted""default"Label text styling variant
containerClassNamestring""CSS classes for the container
labelClassNamestring""CSS classes for the label
triggerKey"Enter" | "Space" | "Comma""Enter"Key that triggers tag addition
maxTagsnumberundefinedMaximum number of tags allowed
schemaZodType<string[]>undefinedZod schema for validation
onValidate(isValid: boolean, value: string[], error?: string) => voidundefinedValidation callback
onChange(tags: string[]) => voidundefinedCallback when tags change

Examples

Pill Variant

Rounded pill variant with muted background styling for modern interfaces.

Pill variant with rounded corners

react
typescript

Press Enter to add tags

Max Tags Limit

Tag input with maximum limit enforcement and validation feedback.

Demonstrates maxTags functionality

JavaScript
React

1 tag remaining (2/3)