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
string
required
Algolia application ID used by the search client.
string
required
Public API key with search permissions for the index.
number
required
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.OnAskAiToggle
required
Callback function when Ask AI mode is toggled.Signature:
(isActive: boolean, initialMessage?: InitialAskAiMessage) => voidIndex Configuration
string
deprecated
Name of the Algolia index to query.Deprecated: Use
indices property instead.Array<DocSearchIndex | string>
default:"[]"
List of indices and optional search parameters to be used for search.
SearchParamsObject
deprecated
Additional Algolia search parameters.Deprecated: Use
indices property instead.Modal Behavior
() => void
Callback function when the modal should close.
boolean
default:"false"
Whether Ask AI mode is currently active.
(initialMessage: InitialAskAiMessage) => boolean | void
Intercept Ask AI requests. Return
true to prevent default Ask AI behavior.string
Query string to prefill when opening the modal.
Ask AI Configuration
DocSearchAskAi | string
Configuration or assistant ID to enable Ask AI mode.
UI Customization
'light' | 'dark'
Theme applied to the modal.
string
Placeholder text for the search input.
ModalTranslations
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
number
Maximum number of hits to display per source/group.
(items: DocSearchHit[]) => DocSearchHit[]
Hook to post-process hits before rendering.
function
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
(searchClient: DocSearchTransformClient) => DocSearchTransformClient
Hook to wrap or modify the Algolia search client.
User Personalization
boolean
default:"false"
Disable storage and usage of recent and favorite searches.
number
default:"7"
Limit of how many recent searches should be saved/displayed.
number
default:"4"
Limit of how many recent searches should be saved/displayed when there are favorited searches.
Navigation
Custom navigator for controlling link navigation.
({ query }: { query: string }) => string
Builds a URL to report missing results for a given query.
Analytics
AutocompleteOptions['insights']
default:"false"
Insights client integration options to send analytics events.
Advanced
boolean
default:"false"
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
