Skip to main content
This example builds on the <Autocomplete> widget guide. It creates a federated autocomplete experience with recent searches and Query Suggestions on the left, and product previews on the right.
This widget is and is subject to change in minor versions.
Federated autocomplete with recent searches and Query Suggestions on the left and product previews on the right (desktop)

Open CodeSandbox

Run and edit the federated autocomplete example in CodeSandbox.

Explore source code

Browse the source code for the federated autocomplete example on GitHub.
The panelComponent arranges the sources into two columns, and each source brings its own header and item components:
React
Add CSS for the columns, product rows, and state-specific elements. The example style sheet includes classes for:
  • Two-column grids
  • Product rows
  • Quick-access cards
  • “See all” and no-results states

Add a quick-access panel

You can show promotional cards or shortcuts when the query is empty. Define them as static data and render them in the panelComponent. When users type a query, show product previews instead:
React
For dynamic cards, return custom data from an Algolia rule. In the panelComponent, read the data from results.userData for the products index instead of using a static array.

Add a category suggestion

To show a category suggestion in the left column, find the products index and read the top product’s categories from results.hits[0] in the panelComponent. Guard against a missing or empty categories attribute, then render the category after the suggestions:
React
The index source has no footerComponent. To show a See all link with the total number of matching results, read the products index’s results.nbHits in the panelComponent and render the link after the product previews:
React

Show the no-results state

When a result source has no items, the widget doesn’t render its itemComponent. Use the source’s noResultsComponent to show a message such as “No products found”, as shown in the main example.

Combine the empty and typing states

The final panelComponent combines two states:
  • For an empty query, show recent and popular searches in the left column and quick-access cards in the right column.
  • After users enter a query, show Query Suggestions and a category in the left column and product previews in the right column.
To switch between the states:
  • Remove the headerComponent from showQuerySuggestions.
  • Render the suggestions heading in the panelComponent. Use “Popular searches” for an empty query and “Suggestions” for a non-empty query.
  • Show the heading only when the Query Suggestions source has results.
For the assembled panelComponent, see src/App.jsx.

See also

Last modified on July 21, 2026