Chat thread
A whole conversation view: messages grouped by day and by sender, a typing row, a reply that streams in, and the message box. It follows the newest message unless the reader has scrolled up, and then offers a Jump to latest button with a count. For a single message, use the chat message.
Install
npx shadcn@latest add @thrum-pro/chat-threadThis is a Pro component. The command works once your project has a licence key: set up Pro or see pricing.
Automatically installs icon arrow-down from the icon set.
Data shape
type ChatThreadMessage = {
id: string;
side?: "incoming" | "outgoing" | "system";
author?: string;
avatar?: string; // picture address
text: string;
time: Date | string;
status?: "sending" | "sent" | "failed";
streaming?: boolean;
};[
{ id: "m1", author: "Mira Kaur", text: "Do you have the renewal date?", time: "2026-12-02T09:12:00Z" },
{ id: "m2", side: "outgoing", author: "You", text: "14 January.", time: "2026-12-03T10:03:00Z", status: "sent" },
{ id: "m3", author: "Mira Kaur", text: "Thanks, drafting the", time: "2026-12-03T10:04:00Z", streaming: true },
]Props
| Prop | Type | Default | Description |
|---|---|---|---|
messages | readonly ChatThreadMessage[] | Required | The messages, oldest first. Stream a reply by updating the text of a message with streaming set, then clear streaming when it is complete. |
label | string | Default "Conversation" | The name of the message list, read by screen readers. |
header | ReactNode | – | Optional header bar shown above the message list (participant name, presence, or actions). |
typing | string | null | Default null | The name of whoever is typing. A row with their initials and three dots shows under the last message. |
onSend | (text: string) => void | – | Called with the trimmed text when the reader sends. Add the message to messages here. Sending always brings the list back to the newest message. |
onStop | () => void | – | Called when the stop button is pressed. The send button turns into it while a message streams or someone is typing. |
onRetry | (id: string) => void | – | Called with a failed message's id when its Retry button is pressed. Without it a failed message shows no Retry. |
promptLabel | string | Default "Message" | The name of the message box. |
placeholder | string | Default "Write a message" | The hint in the empty message box. |
today | Date | – | Today, so day separators can say Today and Yesterday. Without it they print the weekday and date. The thread never reads the clock. |
locale | string | Default "en-US" | The locale of times and day separators. |
timeZone | string | – | The time zone of times and days. Set it when the page is rendered on a server, so the server and the browser print the same. |
emptyLabel | string | Default "No messages yet" | Text shown in the list when there are no messages. |
jumpLabel | string | Default "Jump to latest" | The text of the button that scrolls back to the newest message. |
sound | boolean | Default true | Play subtle cues when sending a message or when a reply arrives, if the visitor has sound on. |
className | string | – | Sets the size. The default height is 384 pixels; the list scrolls inside it and the message box stays at the bottom. |
Motion and sound
Motion
- Nothing moves on load: the list opens at the newest message.
- Newly sent and arriving messages rise 6 px and fade in over 150 ms.
- While the reader is at the bottom, new messages and streamed text keep it there, set before each paint, with no smooth scroll to wait for.
- The typing dots pulse while someone is typing; a streaming reply shows a caret after its text.
- Reduced motion: messages appear at once and the typing dots stand still.
Sound
- A soft select click when sending a message, and a gentle add cue when a new incoming reply completes.
- Nothing plays when the thread first mounts.
Sound is off until the visitor turns it on. Pass sound={false} to keep this component silent. How sound works
Accessibility
- The list is a log, named by label, with polite announcements: a new message is read when the reader pauses.
- A streaming reply is hidden from the log until it is complete, with a hidden Writing note in its place, so it is read once as a whole, never token by token.
- Day separators are text in the list. Each run starts with the sender's name and a time element with the full date in its datetime attribute.
- The typing row is a status that says who is typing. The Jump to latest button says how many messages are new.
- The thread is a panel surface: under frosted glass it turns translucent and its text keeps 4.5:1 contrast. The message box stays solid.
| Keys | Action |
|---|---|
| Tab | Move to the message list, any Retry button, the Jump to latest button when it shows, and the message box. |
| Arrow keys / Page Up / Page Down | On the message list: scroll it. |
| Enter | In the message box: send. Shift with Enter breaks the line. |
| Enter / Space | On Jump to latest: scroll to the newest message and move the focus to the list. |
Source
The source comes with Pro
TypeScript source · Copy-paste ready · MIT-compatible for client projects · Includes all dependencies
Files and dependencies
- Adds
components/chat-thread.tsx- Packages
motion- Brings along
- Chat messagePrompt inputAvatarButtonSeparatorMotion tokensSound engine
- Icons
arrow-down
Changelog
- 1.0.0 · 2026-12-03First release.