Ai · Sidebar
Sidebar
Display configuration and detail information in AI scenarios
Usage Scenarios
The Sidebar is mainly used in AI scenarios for information display and feature configuration, including MCP configuration, reference sources, code preview, rich text preview and editing, etc.
Code Examples
Basic Container
The basic container of the Sidebar is the base container for MCP configuration, Annotation and Sidebar.
visibletogether withonCancelis used to control show/hidetitlesets the titlemotionsets whether to enable the expand animationresizablesets whether the width is resizable. Whentrue, you can useminSizeandmaxSizeto control min and max width
MCP Configuration
Use
MCPConfigure to display, enable/disable, configure and search MCP tools.- Use
optionsandcustomOptionsto set built‑in MCP tools and custom MCP tools - Use
visibleto control show and hide, andonCancelto listen to user close behavior - Use
onStatusChangeto handle enabling/disabling of MCP tools - Use
onAddClickto handle actions after clicking the Add button in custom MCP page - Use
onConfigureClickto listen to configuration of built‑in MCP tools, andonEditClickto listen to configuration of custom MCP tools
For other APIs of MCPConfigure, see MCPConfigureProps.
The type of MCP tool item is as follows:
Usage example:
References
Use the
Annotation component to manage the display of reference sources.- Use
activeKeytogether withonChangeto manage the currently expanded item infosets the reference content list
Code Display
You can use
CodeItem in Sidebar to display code. CodeItem is built based on JsonViewer and CodeHighlight.content: content stringisJson: whether the content is jsonlanguage: programming language name, same aslanguageinCodeHighlightJsonViewerProps: configure other JsonViewer propsCodeHighlightProps: configure other CodeHighlight props
Code List
You can use
CodeContent in Sidebar to display a list of code blocks.Rich Text Editor
You can use
FileItem in Sidebar to view and edit rich text content. FileItem is implemented based on tiptap.content: rich text content, supports the same types as TiptapContenteditable: whether the content is editableimgUploadProps: configure image upload endpoint and how to set the src after upload. Useactionto set upload url andgetUploadImageSrcto return the uploaded image url, which will be used as src of img node in rich text
Rich Text List
You can use
FileContent in Sidebar to display a list of rich text documents.Sidebar
The
Sidebar has a main view (mode is main) and detail views (mode is code, text and other custom values).In the main view you can configure the title through
title, decide whether to show close button through showClose, and configure top button group through options.For content rendering in the main view, you can pass a render function via
renderMainContent. You can use AnnotationContent in Annotation to render references, FileContent in Sidebar to render rich text, and CodeContent to render code.For detail views, if the content is rich text or code, set
mode to code or text and provide detailContent to display the content with built-in code display component / rich text editor. If you want to customize how the detail view is rendered, you can use renderDetailContent to handle it yourself.API Reference
Container
| Property | Description | Type | Default |
|---|---|---|---|
| afterVisibleChange | Callback fired after visible state changes | (isVisible: boolean) => void | - |
| className | Custom class name | string | - |
| containerRef | Ref of the container element | React.RefObject<HTMLDivElement> | - |
| defaultSize | Default size (width/height), only effective when resizable is true | { width?: number | string; height?: number | string } | - |
| maxWidth | Max width, only effective when resizable is true | string | number | - |
| minWidth | Min width, only effective when resizable is true | string | number | - |
| motion | Whether to enable animation | boolean | true |
| onCancel | Callback fired when user cancels/closes | (e: any) => void | - |
| renderHeader | Custom header render function | () => ReactNode | - |
| resizable | Whether the container is resizable | boolean | true |
| showClose | Whether to show close button | boolean | true |
| style | Custom inline style | CSSProperties | - |
| title | Title content | ReactNode | - |
| visible | Whether the container is visible | boolean | - |
MCPConfigure
Supports all props of Container.
| Property | Description | Type | Default |
|---|---|---|---|
| className | Custom class name | string | - |
| customOptions | Custom MCP options | MCPReactOption[] | - |
| filter | Filter function to filter options by input value | (inputValue: string, option: MCPReactOption) => boolean | - |
| onAddClick | Callback when Add button is clicked | (e: MouseEvent) => void | - |
| onConfigureClick | Callback when configure button of built‑in MCP is clicked | (e: MouseEvent, option: MCPReactOption) => void | - |
| onEditClick | Callback when edit button of custom MCP is clicked | (e: MouseEvent, option: MCPReactOption) => void | - |
| onSearch | Callback when search is triggered, returns input value and whether it targets custom MCP | (inputValue: string, custom: boolean) => void | - |
| onStatusChange | Callback when status changes, returns options and whether they are custom | (options: MCPReactOption[], custom: boolean) => void | - |
| options | Built‑in MCP options | MCPReactOption[] | - |
| placeholder | Input placeholder | string | Please enter |
| renderItem | Custom option render function | (option: MCPReactOption,custom: boolean) => ReactNode | - |
| style | Custom inline style | CSSProperties | - |
MCPReactOption
| Property | Description | Type | Default |
|---|---|---|---|
| active | Whether this MCP is active | boolean | false |
| configure | Whether to show configuration related operation/indicator | boolean | false |
| desc | Description content | ReactNode | - |
| disabled | Whether this MCP is disabled. When true, users cannot toggle its active state | boolean | false |
| icon | Icon element | ReactNode | - |
| label | Label text | string | - |
| value | Value | string | - |
Annotation
Supports all props of Container.
| Property | Description | Type | Default |
|---|---|---|---|
| activeKey | Active key(s). Supports single or multiple values | string | string[] | |
| className | Custom class name | string | |
| info | Annotation info list including header, key and reference details | { header: React.ReactNode; key: string; annotations: AnnotationItem[] }[] | |
| onChange | Callback when active item changes, returns current active key(s) | (key: string | string[]) => void | |
| onClick | Callback when a reference is clicked, returns mouse event and reference item | (e: MouseEvent, item: AnnotationItem) => void | |
| renderItem | Custom render function for reference item | (annotation: AnnotationItem) => void | |
| style | Custom inline style | React.CSSProperties |
AnnotationItem
| Property | Description | Type | Default |
|---|---|---|---|
| detail | Extra detail text such as video description or text note | string | - |
| duration | Duration, usually used for videos, in seconds | number | - |
| img | Image url, such as video cover or illustration | string | - |
| logo | Logo url of the site/platform to which the content belongs | string | - |
| onClick | Callback when item is clicked, returns event and current reference item | (event: MouseEvent, item: AnnotationItem) => void | - |
| order | Order/index number | number | - |
| siteName | Name of the site/platform where the content belongs | string | - |
| title | Title | string | - |
| type | Content type | 'video' | 'text' | - |
| url | Resource url. Clicking the reference will open this link | string | - |
Sidebar
| Property | Description | Type | Default |
|---|---|---|---|
| className | Custom class name | string | - |
| detailContent | Content in detail view | DetailContent | - |
| fileEditable | Whether file content is editable | boolean | true |
| imgUploadProps | Image upload related config | ImageUploadNodeOptions | - |
| mode | Display mode, can be main, code, file or other custom strings | string | - |
| onActiveOptionChange | Callback when active option changes, returns mouse event and current active key | (e: MouseEvent, activeKey: string) => void | - |
| onBackWard | Callback when Back is clicked, returns mouse event and current mode, supports async | (e: MouseEvent, mode: string) => void | Promise<any> | - |
| onDetailContentCopy | Callback when content in detail view is copied, returns mouse event, content and copy result | (e: MouseEvent, content: string, res: boolean) => void | - |
| onFileContentChange | Callback when file content changes, returns updated content | (content: string) => void | - |
| renderDetailContent | Custom render function for detail view, receives current mode | (mode: string) => ReactNode | - |
| renderDetailHeader | Custom render function for detail header, receives current mode | (mode: string, detailContent: DetailContent | - |
| renderMainContent | Custom render function for main content, receives current active key | (activeKey: string) => ReactNode | - |
| style | Custom inline style | React.CSSProperties | - |
Code
| Property | Description | Type | Default |
|---|---|---|---|
| activeKey | Active key(s). Supports single string (single select) or string array (multi-select) | string | string[] | - |
| className | Custom class name | string | - |
| codes | Code detail list | CodeItemProps[] | - |
| onChange | Callback when active key changes, returns current active key(s) | (activeKey: string | string[]) => void | - |
| onExpand | Callback when expand is clicked, returns mouse event, corresponding code item and current mode | (e: MouseEvent, code: CodeItemProps, mode: string) => void | - |
| style | Custom inline style | React.CSSProperties | - |
CodeItemProps
| Property | Description | Type | Default |
|---|---|---|---|
| codeHighlightProps | Props for CodeHighlight | CodeHighlightProps | |
| content | Code/text content | string | - |
| isJson | Whether content is JSON | boolean | false |
| jsonViewerProps | Props for JsonViewer | JsonViewerProps | - |
| language | Language type of the code (js, ts, json, etc.). Same as language in CodeHighlight | string | - |
| name | Name | string | - |
File
FileContent
| Property | Description | Type | Default |
|---|---|---|---|
| activeKey | Active key(s). Supports single string (single select) or string array (multi-select) | string | string[] | - |
| className | Custom class name | string | - |
| files | File info list | FileItemProps[] | - |
| onChange | Callback when active key changes, returns current active key(s) | (activeKey: string | string[]) => void | - |
| onExpand | Callback when a file item is expanded, returns mouse event, file item and current mode | (e: MouseEvent, file: FileItemProps, mode: string) => void | - |
| style | Custom inline style | React.CSSProperties | - |
FileItemProps
| Property | Description | Type | Default |
|---|---|---|---|
| className | Custom class name | string | |
| content | Text/content in the editor area | string | |
| editable | Whether content is editable | boolean | |
| extensions | Extension plugins list | Extension[] | |
| imgUploadProps | Image upload related config | ImageUploadNodeOptions | |
| key | Unique key | string | |
| onContentChange | Callback when content changes, returns updated content | (content: string) => void | |
| style | Custom inline style | React.CSSProperties |