Skip to Content

Components API

Diagram

Below is a diagram of the components that make up the package.


Architecture

Root

Chat

NameTypeDefault
styleCSSProperties

The style to apply to the root element.

classNamestring

The class name to apply to the root element.

viewTypeChatViewType

The type of prompt to display.

  • Companion: Smaller prompt screen with session lists.
  • Console: Full screen experience.
  • Chat: Only chat, no sessions.
'console'
sessionsSession[]

The list of sessions to display.

activeSessionIdstring

The ID of the currently active session.

themeChatTheme

Custom theme for the chat.

chatTheme
remarkPluginsPlugin[]

Remark plugins to apply to the request/response.

defaultRemarkPlugins
markdownComponentsComponents

Custom markdown components to override default rendering. Use this to add support for custom elements like charts.

componentsComponentCatalog

A component catalog created via componentCatalog(). Enables dynamic component rendering from LLM responses using fenced code blocks (e.g. ```component).

This automatically wires in the necessary remark plugin and markdown component overrides. For advanced control, use the catalog’s remarkPlugin and components properties directly via the remarkPlugins and markdownComponents props instead.

isLoadingboolean

Whether to display a loading state.

disabledboolean

Whether to disable the chat.

onSelectSession(sessionId: string) => void

Callback function to handle when a session is selected.

onDeleteSession(sessionId: string) => void

Callback function to handle when a session is deleted.

onNewSession() => void

Callback function to handle creating a new session.

onSendMessage(message: string) => void

Callback function to handle sending a new message.

onStopMessage() => void

Callback function to handle stopping the current action.

onFileUpload(file: File) => void

Callback function to handle file upload.

AppBar

NameTypeDefault
contentReactNode

Content to display in the header

themeChatTheme

Custom theme for the appbar

chatTheme

ChatBubble

NameTypeDefault
childrenReactNode

The main content to be rendered.

bubbleContentReactNode

The content to be rendered in the trigger bubble.

positionPlacement

The position of the chat bubble on the screen.

'right-end'
modifiersModifiers

Custom position modifiers.

[offset({ mainAxis: 0, crossAxis: -40 })]
classNamestring

Additional CSS classes to apply to the chat bubble.

Sessions

SessionsList

NameTypeDefault
templatesTemplate[]

Templates to show when no session is active

NewSessionButton

NameTypeDefault
newSessionTextReactNode

Text for the new session button.

'New Session'

SessionGroups

NameTypeDefault
children(groups: GroupedSessions[]) => ReactNode

Render function for the session groups.

SessionsGroup

NameTypeDefault
headingReactNode

Heading for the session group.

SessionListItem

NameTypeDefault
sessionSession

Session to display.

deletableboolean

Indicates whether the session is deletable.

true
deleteIconReactElement<unknown, string | JSXElementConstructor<any>>

Icon to show for delete.

<TrashIcon />
chatIconReactElement<unknown, string | JSXElementConstructor<any>>

Icon to show for chat.

<ChatIcon className="mr-2" />
limitnumber

Limit for the ellipsis.

100

Messages

SessionMessages

NameTypeDefault
classNamestring

Class name to apply to the root element.

newSessionContentReactNode

Content to display when there are no sessions selected or a new session is started.

limitnumber | null

Limit the number of results returned. Clientside pagination.

10
showMoreTextstring

Text to display for the show more button.

'Show more'
autoScrollboolean

Whether to automatically scroll to the bottom of the content.

true
showScrollBottomButtonboolean

Whether to display the scroll to bottom button.

children(conversations: Conversation[]) => ReactNode

Render function for the session messages.

showLoadMoreButtonboolean

Whether to show the load more button.

false
loadMoreButtonDisabledboolean

Whether to disable the load more button.

onScrollUIEventHandler<HTMLDivElement>

Scroll event handler.

onLoadMore() => void

Load more event handler.

SessionMessage

NameTypeDefault
classNamestring

Class name to apply to the root element.

conversationConversation

Conversation to render.

isLastboolean

Whether the message is the last one in the list. This let’s the chat know when to show the loading cursor.

SessionMessagePanel

NameTypeDefault
allowBackboolean

Whether to show the back button to return to the session list in compact mode.

true

SessionMessagesHeader

NameTypeDefault

SessionEmpty

NameTypeDefault

MessageQuestion

NameTypeDefault
questionstring

Question to render.

filesConversationFile[]

Array of sources referenced in the conversation

MessageResponse

NameTypeDefault
responsestring

Response to render.

isLoadingboolean

Whether the response is loading.

MessageActions

NameTypeDefault
questionstring

Question to be copied

responsestring

Response to be copied

copyIconReactElement<unknown, string | JSXElementConstructor<any>>

Icon to show for copy.

thumbsUpIconReactElement<unknown, string | JSXElementConstructor<any>>

Icon to show for thumbs up.

thumbsDownIconReactElement<unknown, string | JSXElementConstructor<any>>

Icon to show for thumbs down.

refreshIconReactElement<unknown, string | JSXElementConstructor<any>>

Icon to show for refresh.

onCopy() => void

Callback function to handle copying.

onUpvote() => void

Callback function to handle upvoting.

onDownvote() => void

Callback function to handle downvoting.

onRefresh() => void

Callback function to handle refreshing.

MessageSources

NameTypeDefault
sourcesConversationSource[]

Sources to render.

MessageSource

NameTypeDefault
limitnumber

Limit for the title.

urlstring

URL of the source, if applicable

titlestring

Title or description of the source

imagestring

Image URL of the source, if applicable.

MessageFiles

NameTypeDefault
filesConversationFile[]

Files to render.

MessageFile

NameTypeDefault
fileIconReactElement<unknown, string | JSXElementConstructor<any>>

Icon to show for delete.

limitnumber

Limit for the name.

namestring

Name of the file

typestring

Type of the file

sizenumber

Size of the file

urlstring

URL of the file

Input

ChatInput

NameTypeDefault
defaultValuestring

Default value for the input field.

allowedFilesstring[]

Allowed file types for upload.

allowMultipleFilesboolean

Allow multiple file uploads.

false
placeholderstring

Placeholder text for the input field.

'Type a message...'
sendIconReactElement<unknown, string | JSXElementConstructor<any>>

Icon to show for send.

<SendIcon />
stopIconReactElement<unknown, string | JSXElementConstructor<any>>

Icon to show for stop.

<StopIcon />
attachIconReactElement<unknown, string | JSXElementConstructor<any>>

Icon to show for attach.

mentionsSuggestionConfig<MentionItem>

Configuration for mentions (@user). Provide items or an onSearch function to enable mentions.

classNamestring

Class name to apply to the container.

commandsSuggestionConfig<SlashCommandItem>

Configuration for commands (/command). Provide items or an onSearch function to enable commands.

minHeightnumber

Minimum height for the input.

24
maxHeightnumber

Maximum height for the input.

200
autoFocusboolean

Whether to auto-focus the input on mount.

true
onMessageChange(message: string) => void

Callback function to handle message change.

RichTextInput

NameTypeDefault
valuestring

Current value of the input

''
placeholderstring

Placeholder text when empty

'Type a message...'
disabledboolean

Whether the input is disabled

false
autoFocusboolean

Whether to auto-focus on mount.

true
classNamestring

Additional CSS classes

minHeightnumber

Minimum height in pixels.

24
maxHeightnumber

Maximum height in pixels.

200
mentionsSuggestionConfig<SuggestionItem>

Configuration for @ mentions

commandsSuggestionConfig<SuggestionItem>

Configuration for / slash commands

onSubmit(value: string) => void

Callback when user submits (presses Enter)

onChange(value: string) => void

Callback when input value changes

MentionList

NameTypeDefault
itemsSuggestionItem[]

List of suggestion items to display

command(item: { id: string; label: string; }) => void

Callback to execute the selected suggestion command

triggerCharstring

The trigger character (e.g., ’@’ or ’/’)

configSuggestionConfig<SuggestionItem>

Configuration for the suggestion popup

querystring

Current search query text

FileInput

NameTypeDefault
allowedFilesstring[]

Array of allowed file extensions.

multipleboolean

Allow multiple file uploads.

isLoadingboolean

Indicates whether a file upload is in progress.

disabledboolean

Disables the file input when true.

attachIconReactNode

Custom icon for the attach button.

onFileUpload(event: ChangeEvent<HTMLInputElement, Element>) => void

Callback function triggered when a file is selected.

Suggestions

ChatSuggestions

NameTypeDefault
suggestionsSuggestion[]

Array of suggestions to display.

classNamestring

Custom class name to apply to the container.

onSuggestionClick(suggestion: string) => void

Callback when a suggestion is clicked.

childrenReactElement<unknown, string | JSXElementConstructor<any>>

Custom render function for each suggestion item. Receives the suggestion data and onClick handler.

ChatSuggestion

NameTypeDefault
onClick(suggestion: string) => void

Callback when the suggestion is clicked.

idstring

Unique identifier for the suggestion

contentstring

The display text for the suggestion

Status

MessageStatus

NameTypeDefault
statusMessageStatusState

Current status state.

'loading'
textstring

Main status text to display.

stepsMessageStatusStep[]

Optional sub-steps to display.

iconReactNode

Custom icon to display. If not provided, uses default icons based on status.

classNamestring

Additional CSS class name.

MessageStatusItem

NameTypeDefault
stepMessageStatusStep

The step to display.

StatusIcon

NameTypeDefault
stateMessageStatusState

Current state of the status icon.

classNamestring

Additional CSS class name for the icon container.

colorClassNamestring

CSS class name for the icon color based on state.

Markdown

Markdown

NameTypeDefault
remarkPluginsPlugin[]

Remark plugins to apply to the markdown content.

rehypePluginsPlugin[]

Rehype plugins to apply to the markdown content.

[rehypeRaw, rehypeKatex]
themeChatTheme

Theme to apply to the markdown content.

customComponentsComponents

Custom components to override default markdown rendering. These will be merged with the default components.

CodeHighlighter

NameTypeDefault
classNamestring

The class name to apply to the code block.

inlineClassNamestring

The class name to apply to the inline code.

languagestring

The language of the code block.

copyClassNamestring

The class name to apply to the copy button.

toolbarClassNamestring

The class name to apply to the toolbar.

copyIconReactElement<unknown, string | JSXElementConstructor<any>>

Icon to show for copy.

<CopyIcon />
themeRecord<string, string>

The theme to use for the code block.

dark

TableComponent

NameTypeDefault

TableHeaderCell

NameTypeDefault

TableDataCell

NameTypeDefault

Component Catalog

ComponentRenderer

NameTypeDefault
rawstring

The raw JSON string from the ```component code block.

definitionsComponentDefinitions

The component definitions from the catalog.

optionsComponentCatalogOptions

Optional catalog options (for onError callback).

ComponentError

NameTypeDefault
variant"error" | "warning"

The visual style variant of the error display. Defaults to β€˜error’.

titlestring

The heading text displayed at the top of the error.

messagestring

The descriptive message explaining the error or warning.

codestring

The raw code or data that caused the error, displayed in a code block.

ChartRenderer

NameTypeDefault
configChartConfig

The chart configuration.

classNamestring

The class name to apply to the chart container.

File Renderers

MessageFile routes attachments to one of these renderers based on the file’s MIME type. They are also exported individually if you want to compose your own file UI.

ImageFileRenderer

NameTypeDefault
namestring

Name of the file.

urlstring

URL of the file.

CSVFileRenderer

NameTypeDefault
namestring

Name of the file.

urlstring

URL of the file.

fileIconReactElement<unknown, string | JSXElementConstructor<any>>

Icon to for file type.

PDFFileRenderer

NameTypeDefault
namestring

Name of the file.

urlstring

URL of the file.

fileIconReactElement<unknown, string | JSXElementConstructor<any>>

Icon to for file type.

DefaultFileRenderer

NameTypeDefault
limitnumber

Limit for the name.

namestring

Name of the file.

urlstring

URL of the file.

fileIconReactElement<unknown, string | JSXElementConstructor<any>>

Icon to for file type.