Skip to content
SevenUI
Sign in
On this page

Message Scroller

Auto-scrolling chat viewport built on the shadcn MessageScroller primitive.

Morning! Ready for the release?
Almost — docs are the last piece.
Which components are left?
The chat family: bubble, message, scroller.
Nice. Screenshots for the changelog too?
Good call, I'll capture them today.
Then let's ship tomorrow morning.
Works for me. Scroll up to test the button!

Installation

Bash

Depends on the @shadcn/react package, installed automatically.

Usage

A chat scroll container that follows streaming output while the reader sits at the live edge, disengages the moment they scroll away, and preserves the visible rows when older history loads above. Rows are real DOM (no virtualization); content-visibility: auto keeps hundreds of turns cheap. Give items stable messageIds for reliable anchoring and jump-to.

API reference

MessageScrollerProvider

Headless root owning scroll state and commands.

PropTypeDefault
autoScrollbooleantrue
defaultScrollPosition"start" | "end" | "last-anchor""end"
scrollEdgeThresholdnumber—
scrollPreviousItemPeeknumber—
scrollMarginnumber—

Use defaultScrollPosition="last-anchor" when reopening saved threads; scrollPreviousItemPeek keeps a slice of the previous turn visible above a new anchor.

MessageScroller and MessageScrollerContent

The styled frame (positions the scroll button) and the transcript column. Extend div via the primitive.

MessageScrollerViewport

The scrollable element. Label it with aria-label.

PropTypeDefault
preserveScrollOnPrependbooleantrue

MessageScrollerItem

Wraps each row for measurement and visibility tracking.

PropTypeDefault
messageIdstring—
scrollAnchorbooleanfalse

Mark conversation-turn boundaries (typically user messages) with scrollAnchor.

MessageScrollerButton

Scroll control rendered through Button (secondary / icon-sm by default, swap via render, variant, size). Hidden and inert while there is nothing to scroll toward.

PropTypeDefault
direction"start" | "end""end"

Hooks

  • useMessageScroller() — returns scrollToMessage(messageId), scrollToEnd(), scrollToStart() for external controls.
  • useMessageScrollerVisibility() — currentAnchorId and visibleMessageIds for position tracking (costs nothing until used).
  • useMessageScrollerScrollable() — whether the viewport can scroll toward start / end.

Was this page helpful?