diff --git a/packages/website/docs/api.mdx b/packages/website/docs/api.mdx index 2638db29..8a59cd73 100644 --- a/packages/website/docs/api.mdx +++ b/packages/website/docs/api.mdx @@ -192,6 +192,42 @@ When provided, an informative message wrapped with your link will be displayed o /> +## `resultsFooterComponent` + +> `type: ({ state }) => JSX.Element` | **optional** + +The component to display below the search results. + +You get access to the [current state](https://github.com/algolia/autocomplete/blob/next/packages/autocomplete-core/src/types/AutocompleteState.ts) which allows you to retrieve the number of hits returned, the query etc. + +[You can find a working example without JSX in this sandbox](https://codesandbox.io/s/docsearch-v3-resultsfootercomponent-without-jsx-jperd5). + +```js +docsearch({ + // ... + resultsFooterComponent({ state }) { + return { + // The HTML `tag` + type: 'a', + ref: undefined, + constructor: undefined, + key: state.query, + // Its props + props: { + href: 'https://docsearch.algolia.com/apply', + target: '_blank', + onClick: (event) => { + console.log(event); + }, + // Raw text rendered in the HTML element + children: `${state.context.nbHits} hits found!`, + }, + __v: null, + }; + }, +}); +``` + @@ -352,6 +388,25 @@ When provided, an informative message wrapped with your link will be displayed o /> +## `resultsFooterComponent` + +> `type: ({ state }) => JSX.Element` | **optional** + +The component to display below the search results. + +You get access to the [current state](https://github.com/algolia/autocomplete/blob/next/packages/autocomplete-core/src/types/AutocompleteState.ts) which allows you to retrieve the number of hits returned, the query etc. + +[You can find a working example in this sandbox](https://codesandbox.io/s/docsearch-v3-resultsfootercomponent-wzie9y). + +```jsx + { + return

{state.context.nbHits} hits found

; + }} +/> +``` +