Docs
Chat Message Area
Chat Message Area
A component that adds auto scrolling functionality to a list of chat messages.
The Chat Message Area component provides a responsive and intelligent scrollable container specifically designed for streamingchat interfaces. It features a sophisticated auto-scrolling system that adapts to user interaction:
- Smart Auto-scroll: Automatically scrolls to new messages when they appear, but only if the user is already at the bottom
- Interaction Awareness: Auto-scroll automatically disables when users scroll up to read previous messages
- Re-engagement: Auto-scroll re-enables when users manually scroll back to the bottom
- Mobile Optimized: On touch devices, auto-scroll pauses while the user's finger is on the screen
- Convenient Navigation: Includes a scroll-to-bottom button that appears when not at the bottom
Installation
pnpm dlx shadcn@latest add https://simple-ai.dev/r/chat-message-area.json
Usage
import { ChatMessageArea } from "@/components/ui/chat-message-area"
<ChatMessageArea className="px-4 py-8 space-y-4">
{/* Your chat messages go here */}
</ChatMessageArea>
Examples
Alignment
You can align the scroll button to the left, right, or center.
Streaming
Try out the auto-scrolling behavior in this live demo. Scroll up to pause auto-scrolling, scroll to bottom to re-enable it, or use the scroll button for quick navigation. On mobile, touch the screen to temporarily pause auto-scroll.