@docsearch/sidepanel-js package provides a vanilla JavaScript implementation of the DocSearch Ask AI sidepanel. This package is ideal for non-React applications that want to add AI-powered search assistance to their documentation.
Installation
sidepanel()
Initializes and mounts a DocSearch Ask AI sidepanel component.Syntax
Parameters
The DOM element or CSS selector where the sidepanel will be mounted.
Your Algolia application ID.
Your Algolia search-only API key.
Ask AI configuration. Can be a simple assistant ID string or a full configuration object.
Array of Algolia index names to search. Can be strings or objects with index name and search parameters.
Display variant for the sidepanel:
floating: Overlays on the right side of the pageinline: Embedded in the page layout
Placeholder text for the search input.
Theme mode for the sidepanel UI.
Localized strings for the sidepanel UI. See Translations for all available strings.
Callback invoked when the sidepanel is mounted and ready for interaction.
Callback invoked when the sidepanel opens.
Callback invoked when the sidepanel closes.
Custom window object for SSR environments. Defaults to global
window.Return Value
Returns a SidepanelInstance object with methods and properties for programmatic control.Examples
Basic Usage
With Lifecycle Callbacks
Inline Variant
With Custom Theme and Translations
SidepanelInstance
The interface returned bysidepanel() provides methods and properties for controlling the sidepanel programmatically.
Properties
Returns
true once the component is mounted and ready for interaction. Read-only.Returns
true if the sidepanel is currently open. Read-only.Methods
Opens the sidepanel. Optionally accepts an initial message to start a conversation.
Closes the sidepanel.
Unmounts the sidepanel component and cleans up all resources. Call this when removing the sidepanel from your application.
Usage Examples
Open with Initial Question
Check State
Clean Up
TypeScript Types
Related
- DocSearchSidepanel (React) - React component version
- Ask AI Configuration - Configure the Ask AI assistant
- Getting Started - Installation and basic setup
