Skip to Content
Liquid Glass UI
Components

MessageScroller

Chat history scroll container that auto-pins to the latest message while preserving reading position, revealing a floating Liquid Glass Jump to Latest button when scrolled up.

Built on @shadcn/react/message-scroller primitives and fully compatible with the standard shadcn/ui JSX API (MessageScrollerProvider / MessageScroller / MessageScrollerViewport / MessageScrollerContent / MessageScrollerItem / MessageScrollerButton, plus useMessageScroller()):

  • Auto-pinning: Automatically follows incoming messages while anchored at the bottom, and preserves reading position without interruption when scrolling up.
  • Liquid Glass Jump button: MessageScrollerButton floats above content as a circular Liquid Glass button with Apple easing scale/fade transitions, automatically switching to Over-Glass on glass surfaces and disabling motion under Reduced Motion.
  • Bottom edge fade: Softly fades the bottom viewport edge with subtle scrollbars hidden during auto-scroll.

Scroll up in the preview below to reveal the Jump to Latest button, or type a message and press Enter to receive an automated reply:

apple-liquid-ui/preview/message-scroller-demo
MacBook · 16:10

Installation (Shadcn Registry)

npx shadcn@latest add @apple-liquid/message-scroller

Usage

import { Bubble, BubbleContent } from '@/components/ui/bubble';
import { Message, MessageContent } from '@/components/ui/message';
import {
  MessageScroller,
  MessageScrollerButton,
  MessageScrollerContent,
  MessageScrollerItem,
  MessageScrollerProvider,
  MessageScrollerViewport,
} from '@/components/ui/message-scroller';

export function Example({ messages }: { messages: { id: string; text: string }[] }) {
  return (
    <MessageScrollerProvider autoScroll defaultScrollPosition="end">
      <MessageScroller className="h-96">
        <MessageScrollerViewport aria-label="Conversation">
          <MessageScrollerContent className="p-3">
            {messages.map((message) => (
              <MessageScrollerItem key={message.id} messageId={message.id}>
                <Message>
                  <MessageContent>
                    <Bubble variant="secondary">
                      <BubbleContent>{message.text}</BubbleContent>
                    </Bubble>
                  </MessageContent>
                </Message>
              </MessageScrollerItem>
            ))}
          </MessageScrollerContent>
        </MessageScrollerViewport>
        <MessageScrollerButton />
      </MessageScroller>
    </MessageScrollerProvider>
  );
}

Props API

MessageScrollerProvider

PropTypeDefaultDescription
defaultScrollPosition'start' | 'end' | 'last-anchor'—Initial scroll position on mount
autoScrollboolean—Auto-follow new messages when anchored at bottom
scrollEdgeThresholdnumber—Distance in px from edge considered "at bottom / top"

MessageScrollerItem

PropTypeDefaultDescription
messageIdstring—Message ID for scrollToMessage() and visibility tracking
scrollAnchorbooleanfalseMarks item as anchor for last-anchor scroll positioning

MessageScrollerButton

PropTypeDefaultDescription
direction'start' | 'end''end'Scroll to newest or oldest message
variantButton['variant']'secondary'Forwarded to the Liquid Glass Button
sizeButton['size']'icon-sm'Forwarded to Button

Language & Text

MessageScroller accepts locale and messages, which apply to all of its parts and the overlays it opens and win over the global <LiquidGlassProvider locale messages>. To override the text globally, put it under messages.messageScroller on the provider. See Liquid Glass → Global settings.

PropTypeDescription
localeLiquidGlassLocaleInputUI language of this component (any BCP 47 tag; unsupported ones fall back to English)
messagesPartial<MessageScrollerMessages>Text overrides, merged over the built-in text and the global messages.messageScroller
KeyBuilt-in text (English)
scrollToEndScroll to end
scrollToStartScroll to start

On this page