Skip to content
Thrum

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-thread

This 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
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;
};
Sample
[
  { 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

PropTypeDefaultDescription
messagesreadonly ChatThreadMessage[]RequiredThe messages, oldest first. Stream a reply by updating the text of a message with streaming set, then clear streaming when it is complete.
labelstringDefault "Conversation"The name of the message list, read by screen readers.
headerReactNode–Optional header bar shown above the message list (participant name, presence, or actions).
typingstring | nullDefault nullThe 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.
promptLabelstringDefault "Message"The name of the message box.
placeholderstringDefault "Write a message"The hint in the empty message box.
todayDate–Today, so day separators can say Today and Yesterday. Without it they print the weekday and date. The thread never reads the clock.
localestringDefault "en-US"The locale of times and day separators.
timeZonestring–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.
emptyLabelstringDefault "No messages yet"Text shown in the list when there are no messages.
jumpLabelstringDefault "Jump to latest"The text of the button that scrolls back to the newest message.
soundbooleanDefault truePlay subtle cues when sending a message or when a reply arrives, if the visitor has sound on.
classNamestring–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.
KeysAction
TabMove to the message list, any Retry button, the Jump to latest button when it shows, and the message box.
Arrow keys / Page Up / Page DownOn the message list: scroll it.
EnterIn the message box: send. Shift with Enter breaks the line.
Enter / SpaceOn Jump to latest: scroll to the newest message and move the focus to the list.

Source

SourcePro

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. 1.0.0 · 2026-12-03First release.

Loading index…

Keyboard shortcuts

/Ctrl KSearch components, docs and actions
?Show this list
AAppearance studio
SSound on or off
MFull or reduced motion
TTheme: auto, light, dark
GSurface: solid or frosted
BBackdrop photograph (under glass)
CCorner radius: square to round
RReplay the demo, on a component page
DDraw new data, on a component page
←→HomeEndMove the cursor in a focused chart
EscClose a dialog, or leave a chart cursor