Skip to content

shadcn.io is not affiliated with official shadcn/ui

Shadcn Message Scroller for React

Chat scroll container that anchors turns, follows streamed replies, and jumps to any message.

Group Chat
A group chat with several participants and an assistant. The Marker is marked as a turn.
@mary, the astrophage line keeps matching Venus energy output. Can you check my math?
Mary (Agent)
Yes. Confirmed. The curve points to a microorganism harvesting stellar energy and breeding near carbon dioxide. If @rocky agrees, this is the clue we need.
ping @rocky
When a user joins, a marker is created. scrollAnchor on the marker marks it as the next turn

Installation

bunx --bun shadcn@latest add https://kit.dev/r/base/message-scroller.json

Anatomy

MessageScrollerProvider
└── MessageScroller
    ├── MessageScrollerViewport
    │   └── MessageScrollerContent
    │       └── MessageScrollerItem
    └── MessageScrollerButton

Usage

import {
  MessageScroller,
  MessageScrollerButton,
  MessageScrollerContent,
  MessageScrollerItem,
  MessageScrollerProvider,
  MessageScrollerViewport,
} from "@/components/ui/message-scroller";
<MessageScrollerProvider>
  <MessageScroller className="max-w-full min-w-0">
    <MessageScrollerViewport>
      <MessageScrollerContent>
        <MessageScrollerItem messageId="1" scrollAnchor>
          {/* message */}
        </MessageScrollerItem>
      </MessageScrollerContent>
    </MessageScrollerViewport>
    <MessageScrollerButton />
  </MessageScroller>
</MessageScrollerProvider>

Demos

Group Chat

Opening Position

Scrollable

State

API Reference