CopilotChatView
Layout component that combines a scrollable transcript with the input area
Overview
CopilotChatView is a layout component that combines a scrollable transcript with the chat input area, suggestion pills, a scroll-to-bottom button, and an optional welcome screen. It is the visual core of the chat interface and is used internally by CopilotChat, CopilotPopup, and CopilotSidebar.
Every visual piece of CopilotChatView is exposed as a slot, so you can replace, style, or extend any part without rewriting the entire layout.
Import
import { CopilotChatView } from "@copilotkit/react-core/v2";
import "@copilotkit/react-core/v2/styles.css";CopilotChatView is a named export of the @copilotkit/react-core/v2
entry point. The package root, @copilotkit/react-core, does not export it.
Slots
CopilotChatView uses the WithSlots pattern. Each slot prop 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. |
Pass a children function to get the messageView, input, scrollView, and suggestionView elements, and arrange them in your own layout. The scrollView element already contains the message view and the suggestions.
Slot Props
Prop
Type
Data Props
Prop
Type
Static Sub-Components
CopilotChatView exposes its default slot implementations as static properties for use in custom compositions:
CopilotChatView.ScrollView-- default scroll container with auto-scroll supportCopilotChatView.ScrollToBottomButton-- default scroll-to-bottom buttonCopilotChatView.Feather-- default feather, an empty elementCopilotChatView.ConnectingIndicator-- default loading indicator shown while a thread connectsCopilotChatView.WelcomeMessage-- default welcome messageCopilotChatView.WelcomeScreen-- default welcome screen layout
Usage
Standalone Usage
function CustomChat({ messages, isRunning }) {
return (
<CopilotChatView
messages={messages}
isRunning={isRunning}
autoScroll={true}
/>
);
}Replacing a Slot with a Custom Component
function CustomDisclaimer(props) {
return (
<div {...props}>Powered by CopilotKit. Responses may contain errors.</div>
);
}
function Chat({ messages, isRunning }) {
return (
<CopilotChatView
messages={messages}
isRunning={isRunning}
input={{ disclaimer: CustomDisclaimer }}
/>
);
}Styling a Slot with a className
function Chat({ messages, isRunning }) {
return (
<CopilotChatView
messages={messages}
isRunning={isRunning}
scrollView="bg-gray-50"
input="border-t border-gray-200"
/>
);
}Custom Layout with Children Render-Prop
function Chat({ messages, isRunning }) {
return (
<CopilotChatView messages={messages} isRunning={isRunning}>
{({ scrollView, input }) => (
<div className="flex flex-col h-full">
<div className="flex-1 overflow-hidden">{scrollView}</div>
{input}
</div>
)}
</CopilotChatView>
);
}Behavior
- Auto-scroll: When
autoScrollistrue, the view uses a stick-to-bottom strategy that keeps the latest message visible. A scroll-to-bottom button appears when the user scrolls up. - Welcome screen: When
messagesis empty andwelcomeScreenis notfalse, a welcome screen is rendered in place of the transcript. The welcome screen also stays hidden while the thread connects (isConnecting) and when the chat targets a specific thread (hasExplicitThreadId). The welcome screen receives theinputandsuggestionViewelements so they can be placed within the welcome layout. - Connecting state: While a thread's initial connect is in flight and no messages have arrived, the
connectingIndicatoris rendered in the transcript area. The root element exposesdata-copilot-connecting="true"for the duration of the connect, so apps can style their own loading state with CSS. - Input container positioning: The input container is absolutely positioned at the bottom of the chat, and the scroll area pads its content to avoid overlap.
- Resize handling: The scroll view monitors input container height changes to keep padding in sync and hides the scroll-to-bottom button during resize transitions.
How is this guide?