Message scroller: Loading earlier messages
Older messages added above keep what you're reading in place (preserveScrollOnPrepend, on by default).
This adds the example as components/examples/message-scroller/history.tsx, together with the Message scroller component and the HextaUI theme tokens it needs.
pnpm dlx shadcn@latest add https://hextaui.com/r/message-scroller-history.jsonTo add only the component, follow the Message scroller installation.
Props in this example
The Message scroller props this example sets, from the API reference.
| Prop | Type | Default |
|---|---|---|
preserveScrollOnPrependKeep the reading position when messages are added above. | boolean | false |
aria-labelNames the conversation region. | string | – |
| Prop | Type | Default |
|---|---|---|
messageIdStable id for following, anchors and counts. | string | – |
| Prop | Type | Default |
|---|---|---|
direction | "start" | "end" | "end" |
Every prop is in the Message scroller API reference.
See them all, with keyboard support and accessibility notes, on the Message scroller page.
- ButtonButtons in every variant and size, with a built-in loading, success and error flow that skips the spinner for fast requests.
- MotionThe easing curves, durations and reduced-motion check every component animates with, plus hooks for size morphs and sliding highlights.
- MessageA chat message row with an avatar, name, bubbles and status, where new messages rise in from the sender's side.
- AttachmentFile and image cards for uploads, with progress, states, actions, a full-card trigger and names that keep their extension.
- BubbleChat message bubbles with variants, grouped corners, reactions and room for interactive content.
- MarkerQuiet notes between content, like date dividers and system events, with sticky dates and times that read as Today or Yesterday.