Skip to content

Message Scroller

A scroll container for chat and feed interfaces that starts at the latest message, keeps its position while history changes, and shows a button to jump back to the newest content.

Message Scroller
New Chat
How can I help you today?
Morning, Shiryoku!
What are we working on today? Press send to start a new conversation
We're shipping offline mode for our notes app next week. Can you check what happens when two devices edit the same note while offline?
Demo is read only. Press send to send messages.

Installation

pnpm dlx shadcn@latest add @sortui/message-scroller

Usage

import {
  MessageScrollerProvider,
  MessageScroller,
  MessageScrollerViewport,
  MessageScrollerContent,
  MessageScrollerItem,
  MessageScrollerButton,
} from "@/components/ui/message-scroller"

Examples

Anchoring Turns

Anchoring Turns
Choose which role settles near the top edge.
No anchored messages yet
Send the first message to see the selected role anchor.
Toggle the anchor role, then send messages to compare where turns settle.

Group Chat

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

This will create a marker and make it the anchor

When a user joins, a marker is created. scrollAnchor on the marker marks it as the next turn

Keeping Context Visible

Keeping Context Visible
New turns keep part of the previous reply in view.

We're shipping offline mode for our notes app next week, and I'm worried about sync conflicts. What happens when two devices edit the same note while offline?

That's the classic sync conflict. Give every edit a timestamp and a device ID, then merge changes paragraph by paragraph when the devices reconnect — most edits touch different parts of a note, so they combine cleanly.

When two devices change the same paragraph, keep both versions and show a small conflict badge on the note. Nothing is overwritten silently, and the writer decides which version wins.

Okay, but a conflict badge on every note sounds noisy. Most of our users only ever write on their phone.
64px
Adjust the slider and send. Observe the previous message peek.

Following the Live Edge

Streaming Messages
Auto-scroll follows the live edge of the conversation.
Ready to Stream
Press send to stream a scripted conversation.
We're shipping offline mode for our notes app next week, and I'm worried about sync conflicts. What happens when two devices edit the same note while offline?
Streaming is simulated. autoScroll is enabled.

Opening Saved Threads

Opening Position
Choose where a saved transcript opens.

This is the first message the user sent in the conversation.

Workspace creation rose 8%, but first invite completion only rose 2%.

This is the last message the user sent in the conversation.

Start with the invite step. Teams are creating workspaces but waiting to add collaborators.

Recommended follow-up:

1. Compare invite drop-off by account size. 2. Check whether users who skip invites still return within 24 hours. 3. Review the empty-state copy on the first project screen. 4. Segment activation by template, since template users may not need invites right away.

If that pattern holds, the next experiment should make collaboration useful earlier instead of prompting for invites harder.

Toggle the defaultScrollPosition to see where the transcript starts when you open the thread

Loading Earlier Messages

Load History
Prepended messages keep your place.

Only the export queue worker changed. The deploy moved large CSV jobs onto the shared retry policy, which made each failed attempt hold a worker slot longer than before.

The app deploy did not include checkout, pricing, or billing API changes.

Do we need to roll back?

Not yet. Queue depth is recovering after we reduced retry concurrency, and the oldest pending job is now under five minutes old.

Keep rollback ready if the queue starts climbing again, but the current trend points toward recovery.

Keep watching for customer-visible issues.

I will watch the queue and support tags for another 15 minutes. I am tracking export failures, delayed download requests, and any support thread that mentions missing reports.

If those stay quiet through the next batch window, we can close this as an internal degradation.

End of Conversation

Restore earlier messages while keeping your place.

Click Load History to load the entire conversation

Animating New Messages

Animation
Choose how user messages are animated when they are added to the conversation.
No Messages Yet
Click the button below to send the first message.
Select an animation then click send to see it in action.

Jumping to Messages

Commands
Drive the transcript from outside.

We're seeing activation dip after workspace creation. Can you help me find the likely step?

The sharpest drop is between creating the workspace and inviting the first teammate.

Workspace creation is still healthy, but the invite step is where users pause. That suggests the product is asking for collaboration before the user has enough confidence in the workspace.

What should I compare before we change the onboarding flow?

Compare three cohorts:

1. Users who choose a template before inviting teammates. 2. Users who start from a blank workspace. 3. Users who skip invites and return within 24 hours.

If template users invite faster, the fix is probably better first-run guidance rather than a louder invite prompt.

Can you turn that into an experiment?

Yes. Create a variant that shows a short checklist after workspace creation:

- Pick a template. - Add one project detail. - Invite a teammate when the workspace has context.

Measure first invite completion, 24-hour return rate, and whether teams create a second project.

What's the risk if we delay the invite prompt?

The main risk is reducing team creation for accounts that already know who they want to invite.

To protect that path, keep the invite action visible in the header and only change the primary empty-state guidance. That gives confident teams a direct route without forcing uncertain users through the invite step too early.

Use the controls to jump to any message in the conversation.

Tracking the Reader's Position

Transcript Outline
Track the current anchored turn.

Review the incident handoff and tell me what to read first.

Start with the summary and the impact section. The regression affected the upload queue, but the recovery path completed for every queued job.

What was the customer impact?

Impact was limited to delayed processing.

No records were dropped, and the reconciliation worker confirmed each retry batch. Support saw confusion from two customers, but there were no checkout or billing errors.

What actions are open?

Keep the retry window enabled until the next deploy, then add a queue-depth alert as the long-term fix.

The alert should fire on sustained queue growth, not a single short spike.

Give me the follow-up checklist.

After that, compare the queue recovery graph with the deploy timeline so the handoff shows exactly when processing returned to baseline. That makes it easier for support and engineering to answer the same customer questions without re-reading the whole incident thread.

I would also add a short owner note beside each follow-up item. The checklist is small, but ownership keeps the retry-window decision, alert tuning, and support macro from drifting into separate follow-up conversations.

Keep the retry window enabled until the next deploy, then add a queue-depth alert as the long-term fix.

The alert should fire on sustained queue growth, not a single short spike.

Open the outline to jump between anchored turns as you read.

Reading Scroll State

Scroll Status
Where the reader can scroll to from the current position.

How did week 1 of my training plan go?

Week 1 is logged: four runs, two strength sessions and one rest day. Your average pace improved by 6 seconds per kilometer.

The plan adds a longer run next week, so keep the easy days easy and let the long run carry the load.

If your legs still feel heavy on Thursday, swap the tempo session for an easy run — the plan adjusts the rest of the week for you.

How did week 2 of my training plan go?

Week 2 is logged: four runs, two strength sessions and one rest day. Your average pace improved by 6 seconds per kilometer.

The plan adds a longer run next week, so keep the easy days easy and let the long run carry the load.

If your legs still feel heavy on Thursday, swap the tempo session for an easy run — the plan adjusts the rest of the week for you.

How did week 3 of my training plan go?

Week 3 is logged: four runs, two strength sessions and one rest day. Your average pace improved by 6 seconds per kilometer.

The plan adds a longer run next week, so keep the easy days easy and let the long run carry the load.

If your legs still feel heavy on Thursday, swap the tempo session for an easy run — the plan adjusts the rest of the week for you.

How did week 4 of my training plan go?

Week 4 is logged: four runs, two strength sessions and one rest day. Your average pace improved by 6 seconds per kilometer.

The plan adds a longer run next week, so keep the easy days easy and let the long run carry the load.

If your legs still feel heavy on Thursday, swap the tempo session for an easy run — the plan adjusts the rest of the week for you.

How did week 5 of my training plan go?

Week 5 is logged: four runs, two strength sessions and one rest day. Your average pace improved by 6 seconds per kilometer.

The plan adds a longer run next week, so keep the easy days easy and let the long run carry the load.

If your legs still feel heavy on Thursday, swap the tempo session for an easy run — the plan adjusts the rest of the week for you.

How did week 6 of my training plan go?

Week 6 is logged: four runs, two strength sessions and one rest day. Your average pace improved by 6 seconds per kilometer.

The plan adds a longer run next week, so keep the easy days easy and let the long run carry the load.

If your legs still feel heavy on Thursday, swap the tempo session for an easy run — the plan adjusts the rest of the week for you.

All messages fit in the viewport.
Scroll the transcript to see the footer update.

Ship your next project this week

Get the full Figma kit, the code of 180+ sections and every future update for one payment.

Get Pro Access