# Chat Thread

> The conversation itself and the lines between its messages.

Component · AI · Pro kit · [Live page](https://ui.twentyfirst.media/pro/components/ChatThread/)

The conversation itself and the lines between its messages.

**ChatThread**: the scrolling log of a conversation. `children` (messages and lines), `jumpTo` (a message `id`: scrolls to it and marks it, e.g. from `SearchHits`), `jumpKey` (to jump to the same one again), `stickToBottom` (default true: follows the newest message while it streams, unless the reader scrolled up; then a button jumps to the latest), `label`.

- **DaySeparator**: "Today", "Yesterday" or the date between days; with `label="New messages"` and `tone="accent"` above the first unread message.
- **HandoffLine**: one agent passes the work to another: `from`, `to` ({name, tint, kind, avatar}), `reason`, `time`, `href` / `onClick` to open their conversation.
- **SystemLine**: what happened around the messages (a model switch, a pause): `icon`, `time`, `tone` ("warning", "danger").
- **VoiceNote**: a voice message: play, seek, length and the transcript behind "Show transcript". `src`, `duration` (seconds), `transcript`, `peaks`, `mine`.
- **VoiceLog**: a finished voice conversation folded into one line: `duration`, `time`, `turns`, `audio` (the recording, if it was kept).
- **TypingIndicator**: "Lena is typing…", "Lena and Noah are typing…", "3 people are typing…".
- **ReadOnlyBar**: in place of the composer while you read along an agent-to-agent conversation, with "Step in".

## Example

```tsx
import {
  ChatMessage,
  ChatThread,
  DaySeparator,
  HandoffLine,
  ReadOnlyBar,
  SystemLine,
  TypingIndicator,
  VoiceLog,
  VoiceNote,
} from "@twentyfirstmedia/pro";

const NOW = "2026-04-16T12:00:00";

export default function Preview() {
  return (
    <div className="tf-panel" style={{ gap: 16, height: 640 }}>
      <ChatThread label="Atlas and Ledger">
        <DaySeparator date="2026-04-15T17:00:00" now={NOW} />
        <HandoffLine
          from={{ name: "Atlas", tint: "sky" }}
          to={{ name: "Ledger", tint: "butter" }}
          reason="Check the prorated amount before the quote goes out"
          time="17:02"
          href="#ledger"
        />
        <ChatMessage
          role="assistant"
          name="Ledger"
          tint="butter"
          time="17:03"
          text="Prorated April is **€480** for 40 seats. Billed with the next invoice."
        />
        <SystemLine icon="clock" time="17:05">
          Atlas paused until the quote is approved
        </SystemLine>
        <DaySeparator date="2026-04-16T09:00:00" now={NOW} />
        <VoiceLog
          duration="2:31"
          time="09:12"
          turns={[
            { who: "user", text: "Did Ledger confirm the amount?" },
            {
              who: "agent",
              name: "Atlas",
              text: "Yes, €480 for April, billed with May's invoice.",
            },
            { who: "user", text: "Then send the quote." },
          ]}
        />
        <DaySeparator label="New messages" tone="accent" />
        <div className="tf-row" style={{ justifyContent: "flex-end" }}>
          <VoiceNote
            mine
            duration={14}
            transcript="Before you send it, add the PO number Ida gave us on the call."
          />
        </div>
        <SystemLine tone="warning" icon="lock">
          Sending the quote needs an approval
        </SystemLine>
        <TypingIndicator names={["Atlas", "Lena Hart"]} />
      </ChatThread>
      <ReadOnlyBar text="You are reading along: Atlas and Ledger" onAction={() => {}} />
    </div>
  );
}
```

## Props

### ChatThread

| Prop | Type | Notes |
| --- | --- | --- |
| `children?` | `ReactNode` |  |
| `jumpTo?` | `string` | Scrolls to the message with this `id` (a search hit) and marks it for a moment. |
| `jumpKey?` | `string \| number` | Change it to jump to the same message again. |
| `stickToBottom?` | `boolean` | Follows the newest message while it grows, unless the reader scrolled up (default true). |
| `label?` | `string` | Accessible name (default "Conversation"). |
| `className?` | `string` | Extra class on the root element. |
| `style?` | `CSSProperties` | Inline style on the root element. |

### DaySeparator

| Prop | Type | Notes |
| --- | --- | --- |
| `date?` | `Date \| string \| number` | The day: shows "Today", "Yesterday" or the weekday and date in the provider's locale. |
| `label?` | `string` | Text instead of the date (e.g. "New messages"). |
| `tone?` | `"neutral" \| "accent"` | "accent" for the "new messages" line (the signal colour). |
| `now?` | `Date \| string \| number` | What counts as today (default now), for stable tests and server rendering. |
| `className?` | `string` | Extra class on the root element. |
| `style?` | `CSSProperties` | Inline style on the root element. |

### HandoffLine

| Prop | Type | Notes |
| --- | --- | --- |
| `from` | `HandoffParty` | Who hands the work over. |
| `to` | `HandoffParty` | Who takes it. |
| `reason?` | `ReactNode` | Why, in a few words. |
| `time?` | `string` |  |
| `id?` | `string` |  |
| `href?` | `string` | Opens the conversation between the two. |
| `onClick?` | `() => void` |  |
| `linkAs?` | `ElementType` |  |
| `className?` | `string` | Extra class on the root element. |
| `style?` | `CSSProperties` | Inline style on the root element. |

### SystemLine

| Prop | Type | Notes |
| --- | --- | --- |
| `children?` | `ReactNode` |  |
| `icon?` | `IconName` |  |
| `time?` | `string` |  |
| `id?` | `string` |  |
| `tone?` | `"neutral" \| "warning" \| "danger"` |  |
| `className?` | `string` | Extra class on the root element. |
| `style?` | `CSSProperties` | Inline style on the root element. |

### VoiceLog

| Prop | Type | Notes |
| --- | --- | --- |
| `title?` | `string` | Default "Voice conversation". |
| `duration?` | `string` | Length as shown ("4:12"). |
| `time?` | `string` |  |
| `turns` | `VoiceTurn[]` | Required |
| `audio?` | `string` | The recording, if it was kept. |
| `audioDuration?` | `number` |  |
| `id?` | `string` |  |
| `open?` | `boolean` |  |
| `defaultOpen?` | `boolean` |  |
| `onOpenChange?` | `(open: boolean) => void` |  |
| `className?` | `string` | Extra class on the root element. |
| `style?` | `CSSProperties` | Inline style on the root element. |

### VoiceNote

| Prop | Type | Notes |
| --- | --- | --- |
| `src?` | `string` | The recording (any URL the browser can play). |
| `duration?` | `number` | Length in seconds (default: read from the file). |
| `transcript?` | `ReactNode` | The words, behind "Show transcript". |
| `transcriptOpen?` | `boolean` |  |
| `onTranscriptOpenChange?` | `(open: boolean) => void` |  |
| `peaks?` | `number[]` | Loudness per moment, 0 to 1, for the bars (default: a steady pattern). |
| `mine?` | `boolean` | Drawn as the user's own (on the primary colour). |
| `label?` | `string` |  |
| `className?` | `string` | Extra class on the root element. |
| `style?` | `CSSProperties` | Inline style on the root element. |

### TypingIndicator

| Prop | Type | Notes |
| --- | --- | --- |
| `names` | `string[]` | Who is typing (renders nothing when empty). |
| `text?` | `string` | Your own text instead of "Lena is typing…". |
| `className?` | `string` | Extra class on the root element. |
| `style?` | `CSSProperties` | Inline style on the root element. |

### ReadOnlyBar

| Prop | Type | Notes |
| --- | --- | --- |
| `text?` | `string` | Default "You are reading along". |
| `actionLabel?` | `string` | Default "Step in". |
| `onAction?` | `() => void` |  |
| `children?` | `ReactNode` |  |
| `className?` | `string` | Extra class on the root element. |
| `style?` | `CSSProperties` | Inline style on the root element. |

### ChatMessage

| Prop | Type | Notes |
| --- | --- | --- |
| `role` | `"user" \| "assistant" \| "system"` | Required |
| `id?` | `string` | Stable id: `ChatThread jumpTo` scrolls to it (rendered as `data-message-id`). |
| `name?` | `string` |  |
| `time?` | `string` |  |
| `model?` | `string` |  |
| `text?` | `string` |  |
| `streaming?` | `boolean` |  |
| `tint?` | `Tint` |  |
| `icon?` | `IconName` | Icon of a system line. |
| `sources?` | `Source[]` |  |
| `attachments?` | `ChatAttachment[]` | Images show as thumbnails, other files as chips with a download link. |
| `mentions?` | `Mention[]` | Mentions in a user's `text` (from `Composer`), drawn as tinted chips. |
| `highlight?` | `string` | Marks the words of a search in the text. |
| `voice?` | `{ src?: string; duration?: number; transcript?: ReactNode; peaks?: number[] }` | A voice message instead of text: the player, its length and the transcript. |
| `dictated?` | `boolean` | "Dictated" under the message. |
| `inVoice?` | `boolean` | "In voice conversation" under the message. |
| `usage?` | `string` |  |
| `onRetry?` | `() => void` | Regenerate: pass it on the last answer only. |
| `onFeedback?` | `(v: "up" \| "down" \| null) => void` | Thumbs up or down (null when the reader takes it back). |
| `onFeedbackComment?` | `(v: "up" \| "down", comment?: string) => void` | The comment after thumbs down (an empty comment for thumbs up). |
| `actions?` | `boolean` | `false` hides the action row; the rest of the props pick which actions show. |
| `actionsVisible?` | `"always" \| "hover"` | When the action row shows: "always", or "hover" (on hover and focus; always on touch screens). Default "always" for an answer with `onRetry` (the last one) and for a message with versions, else "hover". |
| `onEdit?` | `(text: string) => void` | Edit in place on the user's own message: called with the new text. |
| `editing?` | `boolean` | Controls whether the editor is open. |
| `onEditingChange?` | `(editing: boolean) => void` |  |
| `versionIndex?` | `number` | Versions of an edited message or a regenerated answer: "‹ 2/3 ›" (0-based index). |
| `versionCount?` | `number` |  |
| `onVersionChange?` | `(index: number) => void` |  |
| `versionBusy?` | `boolean` | While a version is being made. |
| `before?` | `ReactNode` | Content above the bubble: a tool call, the reasoning, an approval card. |
| `after?` | `ReactNode` | Content below the bubble: an approval card, a form, a result. |
| `children?` | `ReactNode` |  |
| `feedback?` | `"up" \| "down" \| null` |  |
| `linkAs?` | `ElementType` | Router link for relative links in the text. |
| `className?` | `string` | Extra class on the root element. |
| `style?` | `CSSProperties` | Inline style on the root element. |
