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.
  • visible together with onCancel is used to control show/hide
  • title sets the title
  • motion sets whether to enable the expand animation
  • resizable sets whether the width is resizable. When true, you can use minSize and maxSize to control min and max width

MCP Configuration

Use MCPConfigure to display, enable/disable, configure and search MCP tools.
  • Use options and customOptions to set built‑in MCP tools and custom MCP tools
  • Use visible to control show and hide, and onCancel to listen to user close behavior
  • Use onStatusChange to handle enabling/disabling of MCP tools
  • Use onAddClick to handle actions after clicking the Add button in custom MCP page
  • Use onConfigureClick to listen to configuration of built‑in MCP tools, and onEditClick to 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 activeKey together with onChange to manage the currently expanded item
  • info sets 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 string
  • isJson: whether the content is json
  • language: programming language name, same as language in CodeHighlight
  • JsonViewerProps: configure other JsonViewer props
  • CodeHighlightProps: 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 TiptapContent
  • editable: whether the content is editable
  • imgUploadProps: configure image upload endpoint and how to set the src after upload. Use action to set upload url and getUploadImageSrc to 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.
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

PropertyDescriptionTypeDefault
afterVisibleChangeCallback fired after visible state changes(isVisible: boolean) => void-
classNameCustom class namestring-
containerRefRef of the container elementReact.RefObject<HTMLDivElement>-
defaultSizeDefault size (width/height), only effective when resizable is true{ width?: number | string; height?: number | string }-
maxWidthMax width, only effective when resizable is truestring | number-
minWidthMin width, only effective when resizable is truestring | number-
motionWhether to enable animationbooleantrue
onCancelCallback fired when user cancels/closes(e: any) => void-
renderHeaderCustom header render function() => ReactNode-
resizableWhether the container is resizablebooleantrue
showCloseWhether to show close buttonbooleantrue
styleCustom inline styleCSSProperties-
titleTitle contentReactNode-
visibleWhether the container is visibleboolean-

MCPConfigure

Supports all props of Container.
PropertyDescriptionTypeDefault
classNameCustom class namestring-
customOptionsCustom MCP optionsMCPReactOption[]-
filterFilter function to filter options by input value(inputValue: string, option: MCPReactOption) => boolean-
onAddClickCallback when Add button is clicked(e: MouseEvent) => void-
onConfigureClickCallback when configure button of built‑in MCP is clicked(e: MouseEvent, option: MCPReactOption) => void-
onEditClickCallback when edit button of custom MCP is clicked(e: MouseEvent, option: MCPReactOption) => void-
onSearchCallback when search is triggered, returns input value and whether it targets custom MCP(inputValue: string, custom: boolean) => void-
onStatusChangeCallback when status changes, returns options and whether they are custom(options: MCPReactOption[], custom: boolean) => void-
optionsBuilt‑in MCP optionsMCPReactOption[]-
placeholderInput placeholderstringPlease enter
renderItemCustom option render function(option: MCPReactOption,custom: boolean) => ReactNode-
styleCustom inline styleCSSProperties-

MCPReactOption

PropertyDescriptionTypeDefault
activeWhether this MCP is activebooleanfalse
configureWhether to show configuration related operation/indicatorbooleanfalse
descDescription contentReactNode-
disabledWhether this MCP is disabled. When true, users cannot toggle its active statebooleanfalse
iconIcon elementReactNode-
labelLabel textstring-
valueValuestring-

Annotation

Supports all props of Container.
PropertyDescriptionTypeDefault
activeKeyActive key(s). Supports single or multiple valuesstring | string[]
classNameCustom class namestring
infoAnnotation info list including header, key and reference details{ header: React.ReactNode; key: string; annotations: AnnotationItem[] }[]
onChangeCallback when active item changes, returns current active key(s)(key: string | string[]) => void
onClickCallback when a reference is clicked, returns mouse event and reference item(e: MouseEvent, item: AnnotationItem) => void
renderItemCustom render function for reference item(annotation: AnnotationItem) => void
styleCustom inline styleReact.CSSProperties

AnnotationItem

PropertyDescriptionTypeDefault
detailExtra detail text such as video description or text notestring-
durationDuration, usually used for videos, in secondsnumber-
imgImage url, such as video cover or illustrationstring-
logoLogo url of the site/platform to which the content belongsstring-
onClickCallback when item is clicked, returns event and current reference item(event: MouseEvent, item: AnnotationItem) => void-
orderOrder/index numbernumber-
siteNameName of the site/platform where the content belongsstring-
titleTitlestring-
typeContent type'video' | 'text'-
urlResource url. Clicking the reference will open this linkstring-
PropertyDescriptionTypeDefault
classNameCustom class namestring-
detailContentContent in detail view
DetailContent
-
fileEditableWhether file content is editablebooleantrue
imgUploadPropsImage upload related configImageUploadNodeOptions-
modeDisplay mode, can be main, code, file or other custom stringsstring-
onActiveOptionChangeCallback when active option changes, returns mouse event and current active key(e: MouseEvent, activeKey: string) => void-
onBackWardCallback when Back is clicked, returns mouse event and current mode, supports async(e: MouseEvent, mode: string) => void | Promise<any>-
onDetailContentCopyCallback when content in detail view is copied, returns mouse event, content and copy result(e: MouseEvent, content: string, res: boolean) => void-
onFileContentChangeCallback when file content changes, returns updated content(content: string) => void-
renderDetailContentCustom render function for detail view, receives current mode(mode: string) => ReactNode-
renderDetailHeaderCustom render function for detail header, receives current mode(mode: string, detailContent:
DetailContent
) => ReactNode
-
renderMainContentCustom render function for main content, receives current active key(activeKey: string) => ReactNode-
styleCustom inline styleReact.CSSProperties-

Code

PropertyDescriptionTypeDefault
activeKeyActive key(s). Supports single string (single select) or string array (multi-select)string | string[]-
classNameCustom class namestring-
codesCode detail listCodeItemProps[]-
onChangeCallback when active key changes, returns current active key(s)(activeKey: string | string[]) => void-
onExpandCallback when expand is clicked, returns mouse event, corresponding code item and current mode(e: MouseEvent, code: CodeItemProps, mode: string) => void-
styleCustom inline styleReact.CSSProperties-

CodeItemProps

PropertyDescriptionTypeDefault
codeHighlightPropsProps for CodeHighlightCodeHighlightProps
contentCode/text contentstring-
isJsonWhether content is JSONbooleanfalse
jsonViewerPropsProps for JsonViewerJsonViewerProps-
languageLanguage type of the code (js, ts, json, etc.). Same as language in CodeHighlightstring-
nameNamestring-

File

FileContent

PropertyDescriptionTypeDefault
activeKeyActive key(s). Supports single string (single select) or string array (multi-select)string | string[]-
classNameCustom class namestring-
filesFile info listFileItemProps[]-
onChangeCallback when active key changes, returns current active key(s)(activeKey: string | string[]) => void-
onExpandCallback when a file item is expanded, returns mouse event, file item and current mode(e: MouseEvent, file: FileItemProps, mode: string) => void-
styleCustom inline styleReact.CSSProperties-

FileItemProps

PropertyDescriptionTypeDefault
classNameCustom class namestring
contentText/content in the editor areastring
editableWhether content is editableboolean
extensionsExtension plugins listExtension[]
imgUploadPropsImage upload related configImageUploadNodeOptions
keyUnique keystring
onContentChangeCallback when content changes, returns updated content(content: string) => void
styleCustom inline styleReact.CSSProperties