Jump to latest
A chat that follows the answer as it streams, lets go the moment you scroll up, and brings you back.
Used forAI chat windowsAgent transcriptsSupport chat widgetsMessage feeds
Part of AI chat components for React, the parts of a chat in the order they appear.
Install with the shadcn CLI
Registered the namespace? Then it’s shadcn add @hairline/chat-scroll. Set it up
Templates
Need the whole page?
63 Next.js landing pages, each designed from scratch. Try any of them live; one is $39, all of them $159, and 8 are free.
Where it’s used
AI chat windows
Follow the answer as it streams in, without fighting the reader.
Agent transcripts
Long-running agent output that people check on now and then.
Support chat widgets
Keep the newest message in view and show when a reply arrived below.
Message feeds
Team chat or comment threads where new items land at the bottom.
What it handles for you
Every chat needs this and most get it wrong: they drag the reader back down while they are reading, or leave them stranded in the middle of an answer.
It follows the answer
While you are at the bottom, new text keeps the latest line in view.
It lets go at once
The first upward wheel, touch drag, Page Up, Up arrow or Home stops it following, before the next line can pull you back.
A button waits for you
A round ↓ button appears and widens to “Writing” while text arrives, then reads “New reply” when it ends.
It glides back
Click and the chat glides down, chasing the moving bottom, and starts following again.
Late content is handled
Images and code blocks that load after the text no longer push the reader off the bottom.
Keyboard friendly
The area is focusable so the keyboard can scroll it, and the button says what is waiting.
Overview
Every chat needs this, and most get it wrong: they drag you back down while you read, or leave you stranded mid-answer. This scroll area stays pinned to the bottom while text streams in, and lets go the instant you reach for the wheel, trackpad, touch or keyboard. While you’re away a round ↓ button waits; when new text lands below, it widens into "● Writing" under a sweep of light, and when the answer ends the words morph into "New reply" as the pill eases to fit. Click it and the chat glides down, chasing the moving bottom, and starts following again.
States
- following
- At the bottom: new content keeps the latest line in view, with no visible jumps.
- away
- You scrolled up: it stops following immediately and a round ↓ button fades up.
- new below
- Content arrived while you were away: the button widens (380ms) into a pulsing "Writing" while streaming; when it ends, "Writing" morphs into "New reply" and the pulse settles.
- back
- The button glides to the bottom, re-reading it each frame, and following resumes. Changing followKey does the same.
Usage
Depends on lucide-react, installed for you by the CLI along with the keyframes it needs.
Works with
Installs with it
With the AI SDK
Map the Vercel AI SDK’s message parts and chat status onto the component’s props.
Props
- children
- ReactNode
- The messages.
- streaming= false
- boolean
- While true, the button says "Writing" with a pulsing dot.
- followKey
- string | number
- Change it, e.g. to the latest user message id, to glide back to the bottom.
- threshold= 48
- number
- How close to the bottom (px) still counts as at the bottom.
- className / contentClassName
- string
- Give the area a height (or flex-1); style the inner column.
Accessibility and motion
- It lets go on the first upward wheel, touch drag, Page Up, Up arrow or Home, before the next frame of text can pull the reader back.
- The area is focusable, so the keyboard can scroll it; the button names what is waiting ("Still writing below. Jump to latest").
- Following uses a ResizeObserver on the content, so images and code blocks that load late are handled too.
- Installs Text morph. With reduced motion, the jump is instant and the button and its words simply change.
Requirements
React 19, Tailwind CSS v4 and shadcn/ui theme variables (any style, light and dark). Icons from lucide-react.
The CLI also installs Text morph.
Source
Registry item: /r/chat-scroll.json


