Preview not available

Tags Input

An input field that allows users to add and remove tags with validation support.

A tag input component with add/remove functionality, keyboard support (Enter to add), duplicate detection, and optional validation.

Basic

Default

With Initial Tags

Pre-populated

  • React
  • TypeScript
  • Tailwind

Usage

import { TagsInput } from "@delphi/ui";

export function Example() {
  const [tags, setTags] = useState<string[]>([]);

  return (
    <TagsInput
      initialTags={tags}
      onTagsChange={setTags}
      placeholder="Add a tag..."
    />
  );
}

With Validation

import { TagsInput } from "@delphi/ui";

export function ValidatedExample() {
  return (
    <TagsInput
      onTagsChange={(tags) => console.log(tags)}
      onValidateTag={(tag) => tag.length <= 20}
      errorMessage="Tag must be 20 characters or less"
      placeholder="Add a tag..."
    />
  );
}

API Reference

PropTypeDefaultDescription
initialTagsstring[][]Pre-populated tags
onTagsChange(tags: string[]) => voidCalled when tags change
onValidateTag(tag: string) => booleanOptional validation function
errorMessagestringToast message shown on validation failure
placeholderstring"Enter text"Input placeholder text
Use for collecting multiple short text values (tags, emails, keywords)
Provide a meaningful placeholder to guide users
Use validation to enforce tag format constraints
Use for single-value inputs — use a regular Input instead
Allow excessively long tags — validate length
ESC
No results found