Tag Input

The Tag Input component allows users to add, remove, and manage tags dynamically, with optional suggestions.

Usage

Default

Type a tag and press Enter or comma to add. Use arrow keys to navigate suggestions; Enter to select; Escape to close. Backspace removes the last tag when the field is empty.
  • react
  • nextjs

const [tags, setTags] = useState(["react", "nextjs"]);

<TagInput
  tags={tags}
  onChange={setTags}
  placeholder="Add a tag..."
/>

Props

Data table
TypeDescription
aria-describedbystringReferences the ID of an external element that describes the tag input group. Merged with the internal accessibility description/status when provided.
aria-descriptionstringOptional screen reader description for the input behavior. This is announced through an internally rendered description element.
aria-labelstringAccessible label for the overall tag input group. Used when no external aria-labelledby is provided. Defaults to "Tag Input".
aria-labelledbystringReferences the ID of an external element that labels the tag input group. Takes precedence over "aria-label" when provided.
data-testidstringOptional test ID for testing frameworks.
debounceMsnumberDebounce time (ms) for suggestions/autocomplete fetches.
fetchSuggestions((query: string) => Promise<string[]>)Optional function to fetch autocomplete suggestions based on input query. Should return a promise resolving to a string array.
idBasestringCustom ID base for stable accessibility relationships. Can be used to generate predictable ids for label, description, listbox, input, and status elements.
inputAriaDescribedBystringReferences the ID of an external element that describes the text input. Merged with the internal description/status when provided.
inputAriaLabelstringOptional accessible label for the text input itself. Defaults to "Add new tag".
inputAriaLabelledBystringReferences the ID of an external element that labels the text input. Takes precedence over inputAriaLabel when provided.
onChange((tags: string[]) => void)Callback fired when tags change. Receives the new array of tags.
placeholderstringPlaceholder text displayed in the input when empty.
removeTagButtonLabelstringAccessible label prefix for remove-tag buttons. Example output: "Remove tag React". Defaults to "Remove tag".
roundingRoundingTypeRounding style for the input and tags. One of: "none" | "small" | "medium" | "large" | "full"
shadowShadowTypeShadow style for the input and tags. One of: "none" | "light" | "medium" | "strong" | "intense"
sizeSizeTypeSize of the input and tags. One of: "xs" | "small" | "medium" | "large" | "xl"
stateStateTypeState of the input (for feedback/validation). One of: "success" | "error" | "warning" | "disabled" | ""
suggestionsAriaLabelstringAccessible label for the suggestions listbox. Defaults to "Tag suggestions".
tagsstring[]Array of current tags.
themeThemeTypeTheme for styling the input and tags. One of: "primary" | "secondary" | "tertiary" | "quaternary" | "clear"