Skip to main content
Autocomplete is also available as an experimental widget in InstantSearch, making it easier to integrate into your search experience. For more information, see the API reference for InstantSearch.js or React InstantSearch.
This plugin lets you manage and display tags in Autocomplete. You can use tags in various ways, such as displaying filters or representing navigation steps.

Install the plugin

Import the plugin into your project

JavaScript
The plugin includes CSS compatible with autocomplete-theme-classic.
JavaScript
If you don’t use a package manager, you can use the HTML script element:
HTML
To load the tags plugin’s theme:
HTML

Initialize the plugin with initialTags

The plugin lets you pass initialTags for Autocomplete. Use it when deriving tags from an existing state, such as the route or filter status. For example, if the URL reflects the current filter state, you can initialize the plugin with them when the page loads before the Autocomplete instance starts.
JavaScript

Modify tags

By default, the plugin populates a source with the current tags. Users can navigate through them as with any other source and delete them on click or selection. You can customize the source with transformSource. If you want to display tags manually, for example, with the render function or in the search box, you can prevent the plugin from returning a source. The plugin exposes an API on the Context to let you access tags.
Returned tags expose a remove function for removing individual tags.
The plugin also exposes an addTags and a setTags function on the context to update the list of tags.
You can access the same API to retrieve and modify tags directly on the plugin. This is helpful when interacting with tags outside the Autocomplete instance.
JavaScript

Parameters

initialTags
BaseTag<TTag>[]
A set of initial tags to pass to the plugin.You can use this to pass initial refinements (for example, from local state) without triggering the Autocomplete lifecycle.
TypeScript
getTagsSubscribers
(): Array<{ sourceId: string, getTag(params: { item: TItem }): BaseTag<TTag> }>
A function to specify what sources the plugin should subscribe to. The plugin adds a tag when selecting an item from these sources.
  • sourceId: the sourceId of the source to subscribe to.
  • getTag: a function to return a tag from the selected items.
JavaScript
transformSource
function
Type definition
A function to transform the returned tags source.
Example
onChange
(params: OnChangeParams<TTag>): void
TypeScript
The function called when the list of tags changes. This is useful to customize the behavior of Autocomplete when such an event occurs, or integrate with third-party code.

Returns

data

tags
Tag<TTag>[]
TypeScript
Returns the current list of tags.If you’re not using the default tags source returned by the plugin, you can use this to display tags anywhere in your autocomplete.
addTags
(tags: BaseTag<TTag>[]): void
Adds tags to the list.The only required property is a label. You can pass any other property you want, except for remove, which is reserved.
JavaScript
setTags
(tags: BaseTag<TTag>[]): void
Sets the list of tags.This is helpful to replace the current list.
JavaScript
To remove some of the tags, you can retrieve the current tags list using tags and filter it to build a list of tags to keep.
JavaScript
Last modified on May 19, 2026