Chat thread
A React component in Beamline's AI & agents category.
People talking to people: messages grouped by person and day, reactions, delivery and read receipts that glide to the newest message read, who is typing, and a composer with files; it scrolls on the same scroller as the agent conversation.
Use it for
- Person-to-person or team chat inside a product: deal rooms, support handoffs, DMs.
- Threads where delivery, read state and reactions matter.
Not for
- Talking to an agent (conversation + message + response).
- Comments attached to a document or record (comment-thread).
- A feed of system events (timeline).
Anatomy
- root (surface)
- log (Conversation scroller, role log, named)
- day divider (Marker)
- group header: avatar, name, time
- bubble (mine: accent, right; others: surface, left)
- add-reaction button and, after a group's first message, the message's own time: both wait for the row's hover or focus (.reveal; the picker keeps its button shown while open); on touch the reaction button is always shown and the grouped time stays hidden
- reactions (toggle buttons with counts)
- attachments
- delivery status of my newest message (Sending, Sent, Delivered, Read)
- read-by avatars under the last message each person read
- failed line with reason and Retry
- typing line (status)
- jump-to-latest button
- composer: attach, field, send
- room: the thread is a size container; under 24rem a bubble may take 85% of the row (80% above, up to 32.5rem), and under 20rem the log's side padding tightens
Variants
- composer: on (default), off (read-only, archived)
States
- empty (emptyLabel)
- sending
- sent / delivered / read
- failed with Retry
- someone typing
- reading history (jump button)
- files attached to the draft
- controlled draft retained on rejection
- composer pending
- missing handler disabled
Keyboard
- Enter sends, Shift+Enter starts a new line
- Tab reaches each message's reactions and add-reaction button; the picker is a popover (Escape closes, focus returns)
- The log scrolls with the keyboard; Jump to latest is a button
- Sending always takes the thread to the latest message
Motion
A message sent or received while the thread is open rises in (history stays still) and the log follows with the conversation's smooth scroll; a bubble being sent is lighter and settles to full ink when it lands; the delivery word and its mark fade to the new one (Sending → Sent → Read); a new reaction fades in and its count rolls (SlotText); a failure line rises in under its bubble. Read-by avatars glide to the newest message read on the smooth spring (instant with reduced motion); the jump button arrives in --pui-motion-in; typing dots pulse only while someone types (still under reduced motion). Reduced motion keeps the fades and drops the travel.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
participants / currentUserId (required) | ChatParticipant[] / string | — | participants: People who appear as authors in the conversation. Required. currentUserId: Whose side of the thread is "mine" (right, no avatar). |
messages / defaultMessages / onMessagesChange | ChatMessage[] | — | messages: Controlled messages, oldest first. Leave it out to let the thread keep its own list. defaultMessages: Initial messages when uncontrolled. Defaults to an empty list. onMessagesChange: Every change the thread makes to its own list (sent, failed, reacted). |
onSend | (draft: { text, files }) => void | Promise | — | Sends the composer's text and files. Return a promise: the message shows sending, then sent, or failed with the reason. |
onRetry | (messageId) => void | Promise | — | Retry a failed message; without it the thread sends the same text again through onSend. |
onReact / reactions | (messageId, emoji) => void / string[] | — | onReact: Updates a reaction on the specified message; no handler by default. reactions: Emoji offered by the reaction picker. |
typing / readBy | string[] / Record<participantId, messageId> | — | typing: Participant ids currently typing. readBy: The last message each participant has read, by participant id. Their avatar sits under that message and glides as it moves. |
composer / allowAttachments / accept / placeholder | boolean / string | — | composer: Show the composer. Defaults to true. allowAttachments: Lets the composer attach files to a message. Defaults to false. accept: File types the attach button offers, as for `<input accept>`. placeholder: Text shown before a value is entered or selected. Defaults to "Message". |
groupWindow / locale / label / emptyLabel | number / string / ReactNode | — | groupWindow: Messages from one person closer together than this, in ms, share a group. Defaults to five minutes. locale: Locale used for number, date or text formatting. Defaults to the runtime locale. label: Accessible name of the message log. emptyLabel: Said in place of an empty thread. |
classNames | ChatThreadClassNames | — | Classes for the named visual parts; no part overrides by default. |
style / ref | CSSProperties / native Ref | — | style: On ChatComposer: Inline styles on the documented visual root; no inline overrides by default. ref: Receives the documented root element; no ref by default. |
composerClassNames | ChatComposerClassNames | — | Classes for the composer component's named parts; no overrides by default. |
ChatComposer fieldRef | Ref<HTMLTextAreaElement> | — | fieldRef: On ChatComposer: Receives the native field; no ref by default. |
participants (required) | ChatParticipant[] | — | People who appear as authors in the conversation. Required. |
currentUserId (required) | string | — | Whose side of the thread is "mine" (right, no avatar). |
messages | ChatMessage[] | — | Controlled messages, oldest first. Leave it out to let the thread keep its own list. |
defaultMessages | ChatMessage[] | — | Initial messages when uncontrolled. Defaults to an empty list. |
onMessagesChange | ((messages: ChatMessage[]) => void) | — | Every change the thread makes to its own list (sent, failed, reacted). |
typing | string[] | — | Participant ids currently typing. |
readBy | Record<string, string> | — | The last message each participant has read, by participant id. Their avatar sits under that message and glides as it moves. |
onReact | ((messageId: string, emoji: string) => void) | — | Updates a reaction on the specified message; no handler by default. |
reactions | string[] | — | Emoji offered by the reaction picker. |
placeholder | string | — | Text shown before a value is entered or selected. Defaults to "Message". |
composer | boolean | — | Show the composer. Defaults to true. |
allowAttachments | boolean | — | Lets the composer attach files to a message. Defaults to false. |
accept | string | — | File types the attach button offers, as for `<input accept>`. |
groupWindow | number | — | Messages from one person closer together than this, in ms, share a group. Defaults to five minutes. |
locale | string | — | Locale used for number, date or text formatting. Defaults to the runtime locale. |
label | string | — | Accessible name of the message log. |
emptyLabel | ReactNode | — | Said in place of an empty thread. |
ref | Ref<HTMLDivElement> | — | Receives the documented root element; no ref by default. |
ChatComposer.disabled | boolean | — | On ChatComposer: Prevents interaction with the control. Defaults to false. |
ChatComposer.className | string | — | On ChatComposer: Classes on the documented visual root; no override by default. |
ChatComposer.style | CSSProperties | — | On ChatComposer: Inline styles on the documented visual root; no inline overrides by default. |
ChatComposer.fieldRef | Ref<HTMLTextAreaElement> | — | On ChatComposer: Receives the native field; no ref by default. |
reactionPicker | "row" | "search" | — | row: only the `reactions` row; search: the row ends in More, which opens the emoji picker's search and grid in its place. Default row. |
Built from
- conversation
- avatar
- attachment
- marker
- popover
- button
Used in
Dependencies
use-stick-to-bottom, lucide-react, motion, radix-ui
Import
import { ChatThread, ChatComposer } from "@beamline/chat-thread";
Get it
Chat thread is part of Beamline UI. Install the parts you need in your React app as compiled packages or editable source. Get Beamline · Connect your agent
More in AI & agents
- Image generation: The frame an AI image is generated into: a field of brand-hued pixels breathes with the progress while the model works, then the image arrives —…
- Flowchart: A workflow as steps on a dotted canvas: a trigger, conditions that branch into paths side by side, actions and waits, read top to bottom; during a run…
- Run trace: One agent run as a waterfall: every step (model calls, tools, retrieval, checks, sub-agents) nested under the step that started it, each a bar on a…
- Run theatre: One agent run as a theatre: the Run trace's waterfall under a transport (play, scrub, speed) that replays the run as it happened. Pick a step and re-run…
- Answer compare: Two answers to the same prompt side by side, and a person's verdict: A is better, a tie, B is better, or both are bad, with the reasons that decided it…
- Branch navigator: The versions of an assistant conversation that forked when a message was edited or an answer regenerated: a “‹ 2 / 3 ›” switch on each message that has…
- Response: An assistant's answer as streamed markdown in the system's reading type: bursty tokens flow in at an even pace, each new word fades in through a short…
- Model picker: Choose the AI model for a request by what it can do and what it costs: a trigger with the model's name opens a searchable list grouped by provider, with…
- Task rows: Background work an agent is doing, one row per task: status as a glyph and a word, what it produced, how long it has run or took, a progress bar while…
- Conversation: The scrolling column of a conversation: follows new content while you are at the bottom, stops when you scroll up to read, and offers a way back; shared…
- Context cards: The knowledge an agent retrieved before it answered: one card per chunk with what it is about, the text it read with the search words marked, how…
- Prompt suggestions: Ready-made prompts a person can start from or follow up with: chips, cards or a list; a picked one lifts off and flies into the composer as its text…
- Plan: An agent's plan: numbered steps with live status, progress, and Approve / Edit / Reject when it needs sign-off; approving shows progress, and a refusal…
- Approval card: The agent stops and asks before it acts: what it wants to do, exactly what that changes, any choices it needs, and Approve or Reject; both run your…
- Tool call: One tool call in an agent's run: status, what it did and a short result on one quiet row that opens to the exact input and output; stops for permission…
- Recommendation card: One suggestion from the agent that the person may take or leave: what it suggests, why, the expected effect and how sure it is (a meter and a word…
- Citations: Inline numbered citations that preview their source on hover or focus, plus a numbered source list; streamed answers flow in at an even pace with the…
- Reasoning: The agent's trace, fed by your stream: a shimmering label and the seconds so far while it works, then "Thought for N seconds"; steps that check off…
- Attachment: A file tile: preview or typed glyph with the type named, name, size, upload progress, error with retry, and a keyboard-reachable remove.
- Prompt bar: The agent composer: a field that grows, @ to add a source, / for a command, a model picker, files and dictation, and one button that sends with progress…
- Selection actions: Select a passage and hand it to the agent: a bar over the selection with quick actions, your own instruction and More; while the agent works it says so…
- Message: One turn in a conversation with an agent: the person's words in a quiet bubble, the agent's answer on the page with its orb mark, trace, tool calls and…