Skip to content
pandacoderz/ui

Thread

Scroll container that stays pinned to the newest message while content streams in.

Question 1: what does the thread component do?
It keeps the newest message pinned to the bottom while content streams in, and shows a scroll-to-bottom button once you scroll away.
Question 2: what does the thread component do?
It keeps the newest message pinned to the bottom while content streams in, and shows a scroll-to-bottom button once you scroll away.
Question 3: what does the thread component do?
It keeps the newest message pinned to the bottom while content streams in, and shows a scroll-to-bottom button once you scroll away.
Question 4: what does the thread component do?
It keeps the newest message pinned to the bottom while content streams in, and shows a scroll-to-bottom button once you scroll away.
Question 5: what does the thread component do?
It keeps the newest message pinned to the bottom while content streams in, and shows a scroll-to-bottom button once you scroll away.

Installation

npx shadcn@latest add https://ui.spencerwueste.com/r/thread.json

Usage

import {
  Thread,
  ThreadContent,
  ThreadScrollToBottom,
} from "@/components/pandacoderz-ui/thread";
<Thread className="h-[600px]">
  <ThreadContent>
    {messages.map((m) => (
      <Message key={m.id} from={m.role}>…</Message>
    ))}
  </ThreadContent>
  <ThreadScrollToBottom />
</Thread>

Thread must have a bounded height (or be inside a flex column with min-h-0) so the content can scroll.

API Reference

Thread

Wraps use-stick-to-bottom. Accepts its props; resize and initial default to "smooth".

ThreadScrollToBottom

Renders nothing while the viewport is already at the bottom. Accepts asChild to use your own button.