import { CopilotSidebar } from "@copilotkit/react-ui";

<CopilotSidebar
  labels={{
    title: "Your Assistant",
    initial: "Hi! đź‘‹ How can I assist you today?",
  }}
>
  <YourApp/>
</CopilotSidebar>

A chatbot sidebar component for the CopilotKit framework. Highly customizable through various props and custom CSS.

See CopilotPopup for a popup version of this component.

To make the sidebar push your content to the side, wrap your content in the sidebar component. If you want the sidebar to overlay your content, place the sidebar component outside of your content.

Custom CSS

You can customize the colors of the chat window by overriding the CSS variables defined in the default styles.

For example, to set the primary color to purple:

<div style={{ "--copilot-kit-primary-color": "#7D5BA6" }}>
  <CopilotSidebar />
</div>

To further customize the chat window, you can override the CSS classes defined here.

For example:

.copilotKitButton {
  border-radius: 0;
}

Props

instructions
string

Custom instructions to be added to the system message. Use this property to provide additional context or guidance to the language model, influencing its responses. These instructions can include specific directions, preferences, or criteria that the model should consider when generating its output, thereby tailoring the conversation more precisely to the user’s needs or the application’s requirements.

defaultOpen
boolean

Whether the chat window should be open by default.

clickOutsideToClose
boolean

If the chat window should close when the user clicks outside of it.

hitEscapeToClose
boolean

If the chat window should close when the user hits the Escape key.

onSetOpen
(open: boolean) => void

A callback that gets called when the chat window opens or closes.

onInProgress
(inProgress: boolean) => void

A callback that gets called when the in progress state changes.

onSubmitMessage
(message: string) => void

A callback that gets called when a new message it submitted.

shortcut
string

The shortcut key to open the chat window. Uses Command-[shortcut] on a Mac and Ctrl-[shortcut] on Windows.

icons
CopilotChatIcons

Icons can be used to set custom icons for the chat window.

labels
CopilotChatLabels

Labels can be used to set custom labels for the chat window.

makeSystemMessage
SystemMessageFunction

A function that takes in context string and instructions and returns the system message to include in the chat request. Use this to completely override the system message, when providing instructions is not enough.

showResponseButton
boolean

Whether to show the response button.

Window
React.ComponentType<WindowProps>

A custom Window component to use instead of the default.

Button
React.ComponentType<ButtonProps>

A custom Button component to use instead of the default.

Header
React.ComponentType<HeaderProps>

A custom Header component to use instead of the default.

Messages
React.ComponentType<MessagesProps>

A custom Messages component to use instead of the default.

Input
React.ComponentType<InputProps>

A custom Input component to use instead of the default.

ResponseButton
React.ComponentType<ResponseButtonProps>

A custom ResponseButton component to use instead of the default.

className
string

A class name to apply to the root element.

children
React.ReactNode

Children to render.