CopilotPopup
Popup variant of CopilotChat that renders in a floating panel with a toggle button
Overview
CopilotPopup renders a floating chat popup with a toggle button. It wraps CopilotChat and provides popup-specific layout, sizing, and open/close behavior. The popup includes a header with a title and close button, and can be dismissed by clicking outside.
See CopilotSidebar for a sidebar variant of this component.
For a walkthrough, see Popup.
Import
import { CopilotPopup } from "@copilotkit/react-core/v2";
import "@copilotkit/react-core/v2/styles.css";Props
Own Props
Prop
Type
Inherited CopilotChat Props
CopilotPopup accepts all props from CopilotChatProps except chatView, which is set internally to CopilotPopupView. 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:
| Value | Behavior |
|---|---|
| Component | Replaces the default component entirely. Receives the same props the default would. |
className string | Merged into the default component's class list via twMerge. |
| Partial props object | Spread into the default component as additional or overriding props. |
Usage
Basic Usage
function App() {
return (
<CopilotPopup
agentId="my-agent"
labels={{ modalHeaderTitle: "Assistant" }}
/>
);
}Custom Size and Default Open
function App() {
return (
<CopilotPopup
agentId="my-agent"
defaultOpen={true}
width={450}
height="80vh"
clickOutsideToClose={false}
/>
);
}Custom Header
function App() {
return <CopilotPopup agentId="my-agent" header="bg-blue-600 text-white" />;
}Behavior
- Toggle button: Renders a floating toggle button (typically in the bottom-right corner) that opens and closes the popup. The button uses
CopilotChatToggleButtoninternally. - Modal state: Open/close state is managed via the chat configuration context. The
defaultOpenprop sets the initial state; after that, state changes come from user interaction (toggle button, close button, clicking outside). PassopenandonOpenChangeto own the state yourself, and to open or close the popup from your own UI. - Click outside: When
clickOutsideToCloseistrue(the default), clicking anywhere outside the popup panel closes it. - Layout: The popup uses
CopilotPopupViewinternally.CopilotPopupViewbuilds onCopilotChatViewand provides a popup-specific welcome screen layout with the welcome message centered vertically and suggestions just above the input. - Agent connection: All agent wiring (messages, running state, suggestions) is handled by the parent
CopilotChatlogic.
How is this guide?