DocSearchInstance interface is returned by the docsearch() function and provides methods and properties for programmatic control of the DocSearch component.
Interface Definition
Properties
isReady
boolean
Returns
true once the DocSearch component is mounted and ready for interaction.This property is true immediately after the component is rendered to the DOM.isOpen
boolean
Returns
true if the search modal is currently open.Useful for checking modal state before performing actions or syncing UI state with the modal.Methods
open()
() => void
Opens the search modal.If the modal is already open, this method has no effect.
close()
() => void
Closes the search modal.If the modal is already closed, this method has no effect. Automatically refocuses the search button trigger after closing.
openAskAi()
(initialMessage?: InitialAskAiMessage) => void
Opens Ask AI mode in the modal.Requires Ask AI to be configured in the
docsearch() options via the askAi parameter.InitialAskAiMessage
Optional initial message to pre-populate the Ask AI interface.
destroy()
() => void
Unmounts the DocSearch component and cleans up all resources.After calling this method:
- The component is removed from the DOM
- All event listeners are cleaned up
isReadyreturnsfalse- All other methods become no-ops
Complete Usage Example
TypeScript Types
Related
- docsearch() - Initialize DocSearch
- Getting Started - Installation and basic setup
