DocSearchModal component is the modal interface for DocSearch. It’s rendered automatically by the DocSearch component but can also be used standalone for custom implementations where you want full control over the modal lifecycle.
Import
Usage
Props
TheDocSearchModal extends all props from DocSearchProps with additional modal-specific properties.
Required Props
Algolia application ID used by the search client.
Public API key with search permissions for the index.
The window scroll position when the modal was opened. Used to restore scroll position when closing.Typically set to
window.scrollY when opening the modal.Callback function when Ask AI mode is toggled.Signature:
(isActive: boolean, initialMessage?: InitialAskAiMessage) => voidIndex Configuration
Name of the Algolia index to query.Deprecated: Use
indices property instead.List of indices and optional search parameters to be used for search.
Additional Algolia search parameters.Deprecated: Use
indices property instead.Modal Behavior
Callback function when the modal should close.
Whether Ask AI mode is currently active.
Intercept Ask AI requests. Return
true to prevent default Ask AI behavior.Query string to prefill when opening the modal.
Ask AI Configuration
Configuration or assistant ID to enable Ask AI mode.
UI Customization
Theme applied to the modal.
Placeholder text for the search input.
Localized strings for the modal UI.Object with optional properties:
searchBox(SearchBoxTranslations): Search box translationsnewConversation(NewConversationTranslations): New conversation screen translationsfooter(FooterTranslations): Footer translations- Plus screen state translations (noResultsText, etc.)
Results Customization
Maximum number of hits to display per source/group.
Hook to post-process hits before rendering.
Custom component to render an individual hit.Signature:
(props: { hit: InternalDocSearchHit | StoredDocSearchHit; children: React.ReactNode }, helpers?: { html: (template: TemplateStringsArray, ...values: any[]) => any }) => JSX.ElementCustom component rendered at the bottom of the results panel.Signature:
(props: { state: AutocompleteState<InternalDocSearchHit> }, helpers?: { html: (template: TemplateStringsArray, ...values: any[]) => any }) => JSX.Element | nullSearch Client
Hook to wrap or modify the Algolia search client.
User Personalization
Disable storage and usage of recent and favorite searches.
Limit of how many recent searches should be saved/displayed.
Limit of how many recent searches should be saved/displayed when there are favorited searches.
Navigation
Custom navigator for controlling link navigation.
Builds a URL to report missing results for a given query.
Analytics
Insights client integration options to send analytics events.
Advanced
Internal flag for hybrid mode support with sidepanel integration.
Modal Structure
The modal renders with the following structure:Keyboard Navigation
The modal supports full keyboard navigation:- Escape: Close the modal
- Up/Down arrows: Navigate through results
- Enter: Select the highlighted result
- Ctrl/Cmd + K: Close and reopen (when shortcuts enabled)
- Tab: Move focus between elements
Lifecycle
When the modal is opened:- Adds
DocSearch--activeclass todocument.body - Sets CSS variables for viewport height
- Manages scroll position
- Compensates for scrollbar width to prevent layout shift
- Loads recent/favorite searches (if personalization enabled)
- Removes
DocSearch--activeclass fromdocument.body - Restores scroll position to
initialScrollY - Cleans up event listeners
