Skip to main content

Tag Input

StorybookView in Storybook

Explore interactive examples and all component variations in our Storybook.

The TagInput component provides an intuitive way to add and remove tags. Perfect for categorization, filtering, skill selection, or any scenario where you need multiple values in a tag format. Features keyboard navigation, custom separators, and flexible input handling.

Basic Usage

With Helper Text

Press Enter or comma to add tags. Use Backspace to remove the last tag.

Custom Separator

Use pipe (|) or Enter to separate tags

With Initial Values

From String

From Array

Form Integration

Profile Information

e.g., JavaScript, React, Node.js

e.g., Web Development, AI, Design

Tag Management

react
typescript

2 tags selected

Quick Add:

Properties

TagInput

PropertyTypeDescription
valuestring[]Array of current tags (controlled).
onChange(value: string[]) => voidCallback fired when tags change.
initialValuestring | string[]Initial tags value (uncontrolled).
separatorstringCharacter used to separate tags. Default is ",".
placeholderstringPlaceholder text for the input.
helperTextstringHelper text displayed below the input.
classNamestringAdditional CSS classes for the container.
idstringHTML id attribute for the input element.

Accessibility

The TagInput component includes comprehensive accessibility features:

  • Keyboard Navigation - Enter and comma keys add tags, Backspace removes tags
  • Focus Management - Proper focus handling for input and tag removal
  • Screen Reader Support - Tags and actions announced to screen readers
  • ARIA Labels - Descriptive labels for tag removal buttons
  • Form Integration - Works seamlessly with form libraries and validation
  • Visual Feedback - Clear visual indicators for interactive elements

Common Use Cases

The TagInput component is perfect for:

  • Skill Selection - Add programming languages, frameworks, or tools
  • Categorization - Tag content with categories or labels
  • Filtering - Create filter tags for search and data filtering
  • Keywords - Add SEO keywords or metadata tags
  • User Interests - Collect user preferences and interests
  • Product Tags - Tag products with features or characteristics
  • Contact Management - Add labels to contacts or organizations

Best Practices

  1. Clear Instructions - Provide helpful placeholder and helper text
  2. Validation - Validate tags for length, format, or allowed values
  3. Duplicate Prevention - Prevent duplicate tags automatically
  4. Reasonable Limits - Consider setting maximum number of tags
  5. Consistent Separators - Use familiar separators like comma or Enter
  6. Visual Feedback - Show clear states for adding and removing tags
  7. Accessibility - Ensure keyboard navigation and screen reader support
  8. Form Integration - Handle form submission and validation properly