This is the React InstantSearch v7 documentation.
If you’re upgrading from v6, see the upgrade guide.
If you were using React InstantSearch Hooks,
this v7 documentation applies—just check for necessary changes.
To continue using v6, you can find the archived documentation.
<Chat> widget renders the results in a built-in carousel. You can customize it at three levels, from the least to the most involved:
- Restyle the default carousel with CSS.
- Change the markup of each result card with the
itemComponentprop. - Replace the entire carousel layout by overriding the search tool.
Restyle the default carousel with CSS
If the default structure works and you only want a different look, target the carousel’s CSS classes. The search-results carousel uses classes prefixed withais-ChatToolSearchIndexCarousel (for example, ais-ChatToolSearchIndexCarouselHeader). See the styling guide for the full approach.
Customize each result card
Use theitemComponent prop to change what each card in the carousel looks like. The same component is used by both the search-results and recommendations carousels. It receives a single record:
React
Replace the entire carousel layout
To change more than the cards—such as the header, the scroll controls, or the wrapper—override the tool that renders the carousel. Import the tool type and use it as a key in thetools prop:
SearchIndexToolTyperenders the search-results carousel.RecommendToolTyperenders the recommendations carousel.
react-instantsearch. Whatever you pass under a tool key fully replaces the built-in rendering for that tool.
React
layoutComponent receives:
message. The tool call message. The result is onmessage.output(hits,nbHits,queryID); the agent’s parameters are onmessage.input.sendEvent. Sendsclickorconversionevents for the result, using theinsightsmiddleware.applyFiltersandonClose. Apply filters to the InstantSearch UI state, or dismiss the tool’s UI.
Overriding a tool changes only how the result is displayed in the chat. The tool itself—its name, when the agent calls it, and its parameters—is configured on the agent in the Agent Studio dashboard.