Searching Puzzle Pieces

Type to search Puzzle Pieces.

Chat Scroller

A stick-to-bottom message viewport. While you're near the bottom it follows new messages down; scroll up and it hands control back, surfacing a Jump to latest pill. Add a message below and watch it auto-follow — then scroll up first and add another.

Ada Lovelace
Morning! Did the overnight build finish?
The dashboard was still deploying when I logged off.
You
Morning — yep, it went green around 2am.
All 240 tests passing.
Grace Hopper
Nice. I want to walk the release notes before we ship.
Ada Lovelace
Can do. I have the draft ready.
You
Sharing my screen in the standup?
Grace Hopper
Please. And pull up the perf graphs too.
The p95 latency chart especially.
Ada Lovelace
p95 dropped 18% after the caching change — it looks great.
You
Love that. Ship-worthy.
Grace Hopper
Agreed. Let us do a final review at 3.
Ada Lovelace
Works for me.
You
Same. Calendar hold sent.
Grace Hopper
Perfect — talk then.
Pinned — following new messages

Installation

Copy the piece into your app — it compiles with your build and the code is yours:

puzzle add piece chat-scroller

The scroller is the container; the message rows are your own markup — usually a loop of Chat Message rows. It owns only the scroll behavior, never the message data.

Usage

import ChatScroller from '@/components/ui/ChatScroller.pzl';
<ChatScroller height={ 360 } @pin={ setPinned }></ChatScroller>

Pinning

Pinned means the viewport is scrolled within 40px of the bottom. While pinned, a ResizeObserver on the content watches for growth and keeps the newest message in view. Scroll up past the 40px band and pinning disengages: the auto-follow stops and the Jump to latest pill fades in. Clicking it smooth-scrolls to the bottom (instantly under prefers-reduced-motion) and re-pins.

// "Pinned" = within 40px of the bottom. Mirror it in the parent to drive
// UI like an unread badge.
events = {
  setPinned: (isPinned) => this.setData({ pinned: isPinned }),
};

<ChatScroller @pin={ setPinned }> … </ChatScroller>

@pin(isPinned) fires whenever the pinned state flips, so the parent can mirror it — e.g. a "N new messages" badge while the reader is scrolled up.

Accessibility

The viewport carries role="log", which implies aria-live="polite" — assistive tech announces messages as they're appended, without stealing focus. Give it a meaningful label (default "Messages") so the region is named. The Jump to latest pill is a real <button> with a visible focus ring, reachable by keyboard.