Message Scroller
A Duostrap scrollable message stream with sticky bottom-follow and a floating classic jump-to-latest button.
Message Scroller pairs sticky bottom-follow behavior with classic Duostrap 4px panel framing, subtle inset shadows, and beveled button chrome. Appended items scroll into view while the reader is at the bottom, pause while browsing history, and resume on demand via the floating Jump control.
Preview
Section titled “Preview”<div class="h-72 w-full max-w-lg">
<proto-ui-duostrap-message-scroller-root id="bs-chat">
<proto-ui-duostrap-message-scroller-viewport>
<div class="flex flex-col pb-12">
<div>
<strong>Alice</strong>
: Database migration finished on staging.
</div>
<div>
<strong>Bob</strong>
: Verified the read replicas caught up cleanly.
</div>
</div>
</proto-ui-duostrap-message-scroller-viewport>
<proto-ui-duostrap-message-scroller-jump>
Jump to latest ↓
</proto-ui-duostrap-message-scroller-jump>
</proto-ui-duostrap-message-scroller-root>
</div>Installation
Section titled “Installation”Available starting in 0.3.0-rc.1 and later releases. Import the prototypes directly from @proto.ui/prototypes-duostrap/message-scroller and adapt them for your target runtime.
import { messageScrollerRoot, messageScrollerViewport, messageScrollerJump,} from '@proto.ui/prototypes-duostrap/message-scroller';Place Root inside a fixed-height container so Viewport scrolls vertically and Jump floats above the lower-right corner:
<div className="h-72 w-full max-w-lg"> <DuostrapMessageScrollerRoot a11yLabel="Release room messages"> <DuostrapMessageScrollerViewport> <div className="flex flex-col pb-12"> {messages.map((message) => ( <div key={message.id}>{message.text}</div> ))} </div> </DuostrapMessageScrollerViewport> <DuostrapMessageScrollerJump>Jump to latest ↓</DuostrapMessageScrollerJump> </DuostrapMessageScrollerRoot></div>Behavior Notes
Section titled “Behavior Notes”- End-follow policy: Appended entries stay in view only while the reader is already at the bottom. Scrolling up preserves reading position until the user explicitly jumps back.
- Focus preservation: Clicking
Jumpscrolls to the end without stealing keyboard focus. - Count and region naming: Pass
newContentCountfrom your own application state, and usea11yLabelonRootto name the scrollable region (defaults to'Messages').
Examples
Section titled “Examples”Live Operations Log
Section titled “Live Operations Log”Click Append message to stream new lines. Scroll up first to keep your reading position intact while newContentCount increments.
<div class="h-64 w-full max-w-lg">
<proto-ui-duostrap-message-scroller-root id="bs-live">
<proto-ui-duostrap-message-scroller-viewport>
<div id="bs-log" class="flex flex-col pb-12"></div>
</proto-ui-duostrap-message-scroller-viewport>
<proto-ui-duostrap-message-scroller-jump>
Jump to latest ↓
</proto-ui-duostrap-message-scroller-jump>
</proto-ui-duostrap-message-scroller-root>
</div>
<proto-ui-duostrap-button id="bs-append">
Append message
</proto-ui-duostrap-button>Disabled State & Unread Label
Section titled “Disabled State & Unread Label”Jump accepts Button props and uses classic flat disabled chrome without interfering with manual scrolling.
<div class="h-56 w-full max-w-lg">
<proto-ui-duostrap-message-scroller-root id="bs-audit">
<proto-ui-duostrap-message-scroller-viewport>
<div class="flex flex-col pb-12">
<div>14:01 · Worker pool scaled to 6 instances</div>
<div>14:11 · Metrics export resumed normally</div>
</div>
</proto-ui-duostrap-message-scroller-viewport>
<proto-ui-duostrap-message-scroller-jump id="bs-jump">
3 new entries ↓
</proto-ui-duostrap-message-scroller-jump>
</proto-ui-duostrap-message-scroller-root>
</div>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
setElementProps(document.querySelector('#bs-jump'), {
disabled: true,
});
</script>| Prop | Type | Default |
|---|---|---|
newContentCount | number | 0 |
a11yLabel | string | 'Messages' |
Viewport
Section titled “Viewport”| Expose | Type | Notes |
|---|---|---|
atEnd | ExposeState<boolean> | Whether the viewport is currently at the bottom |
following | ExposeState<ScrollEndFollowState> | Current end-follow state |
requestStatus | ExposeState<ScrollEndFollowRequestStatus> | Status of the latest end-follow request |
jumpToEnd() | () => void | Programmatically scroll to the end |
pauseFollowing() | () => ScrollSurfaceRequestOutcome | Pause automatic end-following |
| Prop / Expose | Type | Default |
|---|---|---|
disabled | boolean | false |
atEnd (expose) | ExposeState<boolean> | Mirrored bottom state from Root |
newContentCount (expose) | ExposeState<number> | Mirrored new-content count from Root |