CopilotSidebar

Sidebar variant of CopilotChat that renders in a fixed side panel

Overview

CopilotSidebar renders a fixed sidebar panel for chat interaction. It wraps CopilotChat and provides sidebar-specific layout and open/close behavior. The sidebar includes a header with a title and close button, and can be toggled via a floating button.

See CopilotPopup for a popup variant of this component.

For a walkthrough, see Sidebar.

Import

import { CopilotSidebar } from "@copilotkit/react-core/v2";
import "@copilotkit/react-core/v2/styles.css";

Props

Own Props

Prop

Type

Inherited CopilotChat Props

CopilotSidebar accepts all props from CopilotChatProps except chatView, which is set internally to CopilotSidebarView. This includes:

Prop

Type

The CopilotChatView slots messageView, input, scrollView, and suggestionView are also accepted and forwarded. To pass props to the input, use the input slot, for example input={{ autoFocus: true }}. The disclaimer prop is deprecated. Use input={{ disclaimer: MyDisclaimer }} instead.

Slot System

All slot props follow the same override pattern used across CopilotKit v2 components. Each slot accepts one of three value types:

ValueBehavior
ComponentReplaces the default component entirely. Receives the same props the default would.
className stringMerged into the default component's class list via twMerge.
Partial props objectSpread into the default component as additional or overriding props.

Usage

Basic Usage

function App() {
  return (
    <CopilotSidebar
      agentId="my-agent"
      labels={{ modalHeaderTitle: "Assistant" }}
    />
  );
}

Default Open with Custom Width

function App() {
  return <CopilotSidebar agentId="my-agent" defaultOpen={true} width={500} />;
}

Custom Header

function App() {
  return (
    <CopilotSidebar agentId="my-agent" header="bg-indigo-700 text-white" />
  );
}

Behavior

  • Toggle button: Renders a floating toggle button that opens and closes the sidebar. The button uses CopilotChatToggleButton internally.
  • Modal state: Open/close state is managed via the chat configuration context. The defaultOpen prop sets the initial state; after that, state changes come from user interaction (toggle button, close button in the header). Pass open and onOpenChange to own the state yourself, and to open or close the sidebar from your own UI.
  • Layout: The sidebar uses CopilotSidebarView internally. CopilotSidebarView builds on CopilotChatView and provides a sidebar-specific welcome screen layout with the welcome message centered and the suggestions just above the input at the bottom.
  • Fixed positioning: The sidebar renders as a fixed panel on one side of the viewport. On screens 768 px wide or wider, the open sidebar adds a margin to document.body on its side, so your page content moves aside. On narrower screens, it covers the page.
  • Agent connection: All agent wiring (messages, running state, suggestions) is handled by the parent CopilotChat logic.

How is this guide?