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.
Improving the search experience often means adding several sources of data, such as in a federated search. Doing this in an organized and efficient way can be challenging. To make the most od larger display on devices such as desktops and tablets, you should display data in a multi-column layout. This lets users quickly browse search results and reduces scrolling. An experience using a two-column layout with Autocomplete

Before you begin

This tutorial assumes the following requirements:
  • An installation of the autocomplete-js package.
  • A populated Query Suggestions . If you don’t have one, create it: you can use the example application credentials and index provided in this tutorial.
  • Existing HTML with an input element where you want to insert the autocomplete drop-down menu.
  • Frontend development experience with HTML, CSS, and JavaScript.

Starter code

This tutorial builds an Autocomplete app composed of two columns: Create a file called app.js in your src directory and add this code to it:
JavaScript
This starter code assumes you want to insert the autocomplete into a DOM element with autocomplete as an id. Change the container to match your markup. Setting openOnFocus to true ensures that the drop-down menu appears as soon as a user focuses the input.

Two-column layout

With the render function of autocomplete-js, you can customize the panel rendering to create two or more columns.

Add recent searches and Query Suggestions

Add the recent searches (with a limit of two recent searches) and Query Suggestions plugin (limiting the number of suggestions to seven) to the left column. This gives a total of nine items in the right column. Then, retrieve the recent searches and query suggestions plugins sources in the render function using elements and add it to the left column.

Create a “products” source

Add a source to retrieve and display the products in the right column. Create a dynamic source using the getSources function and retrieve the products from your Algolia index with the getAlgoliaResults function.

Display products

Now that you’ve set up your source, you can display products with templates.

Create a product item component

Start by creating a file called ProductItem.js in your src directory, then copy and paste the following code (a component used to render each item of your source):

Render each source item

To render each source item, use the templates option in your source with the item function.

Add styles

Copy and paste the following CSS snippet in your src directory and call it style.css.
CSS
Make sure to include it in your project’s app.js file.
JavaScript

Next steps

This tutorial focuses on building a multi-column layout but you can improve it by: For an example, this two-column layout implements these features.
Last modified on May 19, 2026