@@ -5,6 +5,8 @@ description: live demos showing how to use and extend docsearch beyond documenta
55---
66
77import { DocSearch } from ' @docsearch/react' ;
8+ import { DocSearch as DocSearchProvider } from ' @docsearch/core' ;
9+ import { DocSearchButton , DocSearchModal } from ' @docsearch/modal' ;
810import { DocSearchSidepanel } from ' @docsearch/react/sidepanel' ;
911import BrowserOnly from ' @docusaurus/BrowserOnly' ;
1012import ' @docsearch/css/dist/style.css' ;
@@ -98,6 +100,51 @@ The sidepanel provides a persistent chat interface anchored to the side of the p
98100
99101---
100102
103+ ## Composable API: DocSearchButton + DocSearchModal
104+
105+ Use the [ Composable API] ( /docs/composable-api ) to render the button and modal as separate components. This gives you explicit control over where each piece is rendered and when the modal code is loaded.
106+
107+ ``` jsx
108+ import { DocSearch } from ' @docsearch/core' ;
109+ import { DocSearchButton , DocSearchModal } from ' @docsearch/modal' ;
110+
111+ import ' @docsearch/css/style.css' ;
112+
113+ < DocSearch>
114+ < DocSearchButton translations= {{ buttonText: ' Composable search (demo)' }} / >
115+ < DocSearchModal
116+ appId= " PMZUYBQDAK"
117+ indexName= " docsearch"
118+ apiKey= " a00716d83c64f6c61905c078b7d5ab66"
119+ askAi= {{
120+ assistantId: ' ccdec697-e3fe-465b-a1c3-657e7bf18aef' ,
121+ agentStudio: true ,
122+ }}
123+ / >
124+ < / DocSearch> ;
125+ ```
126+
127+ <BrowserOnly >
128+ { () => (
129+ <DocSearchProvider >
130+ <DocSearchButton
131+ translations = { { buttonText: ' Composable search (demo)' }}
132+ />
133+ <DocSearchModal
134+ appId = " PMZUYBQDAK"
135+ indexName = " docsearch"
136+ apiKey = " a00716d83c64f6c61905c078b7d5ab66"
137+ askAi = { {
138+ assistantId: ' ccdec697-e3fe-465b-a1c3-657e7bf18aef' ,
139+ agentStudio: true ,
140+ }}
141+ />
142+ </DocSearchProvider >
143+ )}
144+ </BrowserOnly >
145+
146+ ---
147+
101148## Custom hit rendering (` hitComponent ` )
102149
103150Replace the default hit markup to match your brand and layout. below is a minimal example of a custom component.
0 commit comments