examples/v2/docs/reference/copilot-chat-scroll-view.mdx
CopilotChatScrollView is the default scroll container used by CopilotChat. It handles auto-scrolling during message streaming, provides a scroll-to-bottom button, and displays a gradient fade (feather) overlay.
The CopilotChatScrollView component:
CopilotChatScrollView provides slots for customizing its visual elements:
graph LR
SV[CopilotChatScrollView] --> scrollToBottomButton
SV --> feather
| Slot | Description |
|---|---|
scrollToBottomButton | Button that appears when scrolled up from bottom |
feather | Gradient fade overlay at the bottom of the scroll area |
Customize the scroll view through the scrollView prop on CopilotChat:
<CopilotChat
scrollView={{
scrollToBottomButton: "bg-blue-500 hover:bg-blue-600",
}}
/>
By default, CopilotChatScrollView automatically scrolls to the bottom when:
To disable auto-scroll:
<CopilotChat autoScroll={false} />
When auto-scroll is disabled, users must manually scroll to see new messages. The scroll-to-bottom button will appear when new content is available below the viewport.
CopilotChatScrollView uses the slot system. Each slot accepts four types of values:
Style the scroll-to-bottom button:
<CopilotChat
scrollView={{
scrollToBottomButton: "bg-blue-500 shadow-xl rounded-full",
}}
/>
Or with a custom component:
function CustomScrollButton({ onClick }) {
return (
<button
onClick={onClick}
className="px-4 py-2 bg-gradient-to-r from-blue-500 to-purple-500 text-white rounded-lg shadow-lg"
>
Jump to latest
</button>
);
}
<CopilotChat
scrollView={{
scrollToBottomButton: CustomScrollButton,
}}
/>;
The feather provides a gradient fade at the bottom of the scroll area:
<CopilotChat
scrollView={{
feather: "from-blue-50 via-blue-50 to-transparent",
}}
/>
To remove the feather entirely:
<CopilotChat
scrollView={{
feather: () => null,
}}
/>
To completely replace the scroll view with your own component:
import { CopilotChatView } from "@copilotkit/react-core";
function CustomScrollView({ children, autoScroll, ...props }) {
return (
<CopilotChatView.ScrollView
autoScroll={autoScroll}
scrollToBottomButton="bg-indigo-600"
feather="from-gray-50 via-gray-50 to-transparent"
{...props}
>
{children}
</CopilotChatView.ScrollView>
);
}
<CopilotChat scrollView={CustomScrollView} />;
<CopilotChat
scrollView={{
scrollToBottomButton: {
className:
"bg-gradient-to-r from-pink-500 to-orange-500 text-white shadow-xl",
},
}}
/>
<CopilotChat
scrollView={{
feather: "from-gray-900 via-gray-900 to-transparent",
}}
/>
Remove both the scroll button and feather for a minimal look:
<CopilotChat
scrollView={{
scrollToBottomButton: () => null,
feather: () => null,
}}
/>
<CopilotChat
className="bg-slate-50"
scrollView={{
className: "bg-slate-50",
scrollToBottomButton: "bg-slate-700 hover:bg-slate-800 text-white",
feather: "from-slate-50 via-slate-50 to-transparent",
}}
/>