Blocks / Thread panel

Thread panel

A side panel: the root message, its replies, a composer, close.

import { ThreadPanel } from "@forgeron/ui";
/01 → Default
import { ThreadPanel, type ConversationMessage } from "@forgeron/ui";
import { useState } from "react";

const lea = { id: "lea", name: "Léa Martin" };
const me = { id: "me", name: "You" };

const root: ConversationMessage = {
  id: "r",
  at: "2026-11-19T08:55:00Z",
  author: lea,
  body: "Found it: the **webhook** is sent twice. Thoughts?",
};

export default function Default() {
  const [replies, setReplies] = useState<ConversationMessage[]>([
    {
      id: "1",
      at: "2026-11-19T09:02:00Z",
      author: me,
      body: "Add an idempotency key on our side.",
    },
    { id: "2", at: "2026-11-19T09:10:00Z", author: lea, body: "Agreed, I will open a PR." },
  ]);
  return (
    <div
      style={{ height: 520, width: "100%", maxWidth: 420, border: "1px solid var(--line-strong)" }}
    >
      <ThreadPanel
        root={root}
        replies={replies}
        currentUserId="me"
        typing={["Léa"]}
        list={{ now: "2026-11-19T12:00:00Z" }}
        timeZone="UTC"
        onClose={() => {}}
        onSend={({ text }) =>
          setReplies((r) => [
            ...r,
            { id: `n${r.length}`, at: new Date().toISOString(), author: me, body: text },
          ])
        }
        onReact={() => {}}
      />
    </div>
  );
}
API → Props
PropTypeDefaultDescription
root / repliesConversationMessage; ConversationMessage[]—The message and its answers, oldest first.
onSend(message) => void—A reply sent from the composer.
onClose() => void—The button and Escape.
composer / listPartial<RichComposerProps>; Partial<MessageListProps>—Passed to the composer and the list.
typing / titlestring[]; string—Who is writing in the thread; the heading.
currentUserIdstring—Whose messages are yours: edit and delete are offered on them, they are marked.
onReact(messageId, emoji) => void—An emoji pressed or chosen on a message. The caller adds or removes it (toggleConversationReaction).
onReply / onOpenThread(message) => void—Reply (the caller fills the composer's reply bar); open the thread of a message.
onEdit / onDelete / onCopy(message) => void—Edit and delete are offered on your own messages; copy uses the clipboard by default.
onRetry / onDiscard(message) => void—On a message whose status is failed.
actions / onAction(message) => ActionMenuEntry[]; (id, message) => void—More rows in each message's menu. onAction also hears the usual ids (reply, thread, copy, edit, delete).
onMentionClick({ char, id, label }) => void—Mentions become buttons.
timeZonestring—IANA zone for days and times; the device's by default.
classNamestring—Extra classes.