Skip to content
Browse docs and components

Message Scroller

message-scroller

The scrolling transcript of a chat: it follows a streaming reply, lets go the moment you scroll up, and brings you back with a Jump to latest pill. An optional rail of ticks previews and jumps to any message.

Responsive

Install

$npxshadcnadd@forme/message-scroller

Adds the component, its registry dependencies, and the token stylesheet you import once.

Usage

import { MessageScroller } from "@/components/forme/message-scroller/message-scroller";

<MessageScroller busy={streaming} rail className="h-[32rem]">
  {messages.map((message) => (
    <ChatMessage key={message.id} from={message.from}>{message.text}</ChatMessage>
  ))}
</MessageScroller>

When to use

Reach for it

  • The transcript of a chat or a log that grows while it is read.

Use something else

  • Static lists that never grow while they are on screen — an ordinary scroll area is enough.

API reference

Read from the source, so it is the API of the file you install. A prop marked * is required.

MessageScroller

The scrolling transcript of a conversation. It keeps a streaming reply in view, lets go the moment the reader scrolls up to read something older, and offers a way back.

PropTypeDefaultDescription
labelstring"Conversation"Names the transcript for screen readers.
followbooleantrueKeep new output in view while the reader is at the end. On by default.
thresholdnumber48How close to the end, in pixels, still counts as being at it.
railbooleanfalseA column of ticks beside the transcript, one per message, to jump between them.
busyboolean—True while a reply streams, so screen readers wait for it to settle before reading it.
onFollowChange(following: boolean) => void—Called when the reader leaves the live end, and when they return to it.
contentClassNamestring—

Also takes every prop of <div> attributes.

Accessibility

  • The transcript is a labelled log, and busy tells screen readers to wait while a reply streams.
  • A “Jump to latest” pill appears when the reader has scrolled away, and says “New messages” when something arrives.

Motion

  • It follows a stream instantly rather than smoothly, because a smooth scroll chasing growth lags a line behind.
  • Any scroll up lets go of the live end; reaching the end again, or sending a message, rejoins it.
  • Jumping back is smooth, and instant with reduced motion.