Skip to content
loseta

Components / Conversation

Message Scroller

A scroll container for conversations with a jump-to-latest button.

Status stableWorks with bubble, message, avatar, marker
Today
CN
shadcn
I checked the registry build.
YO
Did the docs bundle pick up the new files?
CN
Yes. The main stylesheet includes the base and Nova files.
YO
Great. Run the registry validator before the browser suite.
CN
Both are green. The chat components are ready for review.
YO
Then this scroller needs enough history to prove the jump button.
CN
Scroll up and the jump button appears; it returns you here.
<div class="message-scroller" style="height: 22rem">
  <div class="message-scroller-viewport" tabindex="0" role="log" aria-label="Conversation">
    <div data-slot="content">
      <div class="marker" data-variant="separator">
        <span data-slot="content">Today</span>
      </div>
      <div class="message" data-align="start">
        <div data-slot="avatar"><span class="avatar" data-size="sm"><span data-slot="fallback">CN</span></span></div>
        <div data-slot="content">
          <div data-slot="header">shadcn</div>
          <div class="bubble" data-variant="muted"><div data-slot="content">I checked the registry build.</div></div>
        </div>
      </div>
      <div class="message" data-align="end">
        <div data-slot="avatar"><span class="avatar" data-size="sm"><span data-slot="fallback">YO</span></span></div>
        <div data-slot="content">
          <div class="bubble"><div data-slot="content">Did the docs bundle pick up the new files?</div></div>
        </div>
      </div>
      <div class="message" data-align="start">
        <div data-slot="avatar"><span class="avatar" data-size="sm"><span data-slot="fallback">CN</span></span></div>
        <div data-slot="content">
          <div class="bubble" data-variant="muted"><div data-slot="content">Yes. The main stylesheet includes the base and Nova files.</div></div>
        </div>
      </div>
      <div class="message" data-align="end">
        <div data-slot="avatar"><span class="avatar" data-size="sm"><span data-slot="fallback">YO</span></span></div>
        <div data-slot="content">
          <div class="bubble"><div data-slot="content">Great. Run the registry validator before the browser suite.</div></div>
        </div>
      </div>
      <div class="message" data-align="start">
        <div data-slot="avatar"><span class="avatar" data-size="sm"><span data-slot="fallback">CN</span></span></div>
        <div data-slot="content">
          <div class="bubble" data-variant="muted"><div data-slot="content">Both are green. The chat components are ready for review.</div></div>
        </div>
      </div>
      <div class="message" data-align="end">
        <div data-slot="avatar"><span class="avatar" data-size="sm"><span data-slot="fallback">YO</span></span></div>
        <div data-slot="content">
          <div class="bubble"><div data-slot="content">Then this scroller needs enough history to prove the jump button.</div></div>
        </div>
      </div>
      <div class="message" data-align="start">
        <div data-slot="avatar"><span class="avatar" data-size="sm"><span data-slot="fallback">CN</span></span></div>
        <div data-slot="content">
          <div class="bubble" data-variant="muted"><div data-slot="content">Scroll up and the jump button appears; it returns you here.</div></div>
        </div>
      </div>
    </div>
  </div>
  <button type="button" data-slot="jump" aria-label="Jump to latest"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 5v14"/><path d="m19 12-7 7-7-7"/></svg></button>
</div>

Installation

pnpm dlx loseta add message-scroller
npx loseta add message-scroller

Accessibility and behavior

  • The viewport is the scroll container and needs tabindex="0" and an accessible name. Following new messages, anchoring, scroll position and showing [data-slot="jump"] are consumer JavaScript; the jump button needs an accessible label.

Files

components/message-scroller.cssbase
styles/nova/message-scroller.cssstyle

Install contract

The CLI writes the base file under components/, the visual file for the selected style under styles/<name>/, and any primitive dependency underprimitives/. The generated index.css imports them in the right layer order.

← Back to components

loseta is MIT licensed. Built with native CSS, no runtime. Inspired byshadcn/ui.