Thread
One comment thread for any subject: replies, person and agent authors, resolve, a canvas pin and labels you can translate.
Activity
- Ada Okafor 22 Oct
The three plans fit one screen on a laptop. Can we cut the table under it?
- Scribe AI 22 Oct
Cut it. The comparison now sits in the plan cards, 4 rows each.
- Ada Okafor 22 Oct
Pin this on the pricing node: the headline still says per seat.
Installation
pnpm add @heyramzi/uiUsage
import {
Thread,
type ThreadComment,
type ThreadLabels,
type ThreadPost,
} from "@heyramzi/ui/thread";<Thread
{comments}
{onPost}
{onEdit}
{onDelete}
{onResolve}
canEdit={(comment) => comment.author.kind === "user"}
/>Keyboard and accessibility
| Key | Does |
|---|---|
| Tab | Moves through each comment's buttons, then the composer. |
| Cmd Enter Ctrl Enter | Sends the comment or reply from its text box. |
| Esc | In a reply or edit box, cancels it. |
- The thread is a section named by its title. Comments are a list, with replies nested under them.
- Resolve, edit and delete show on hover, or as soon as focus enters the comment.
- Opening a reply or an edit puts focus in its box.
- Save, Cancel and Esc return focus to Edit. Closing or sending a reply returns it to Reply.
- After a delete, focus goes to the next comment, or the one before when it was the last.
- Resolve and "Show resolved" are toggles that report pressed.
- An agent's name is followed by a hidden word saying it's an agent.
API reference
commentsrequiredThreadComment[]eventsThreadEvent[]- Default
[] - Status moves, assignments and the like, one quiet line each between the comments.
loadingboolean- Default
false - Rows still on their way. Draws skeleton rows in place of the thread.
labelsPartial<ThreadLabels>avatarSnippet<[ThreadComment]>- Replaces the default avatar for a person or an agent, drawn in a 24px slot.
attachmentsSnippet<[ThreadComment]>- Content under a comment's body, such as files.
anchorChipSnippet<[ThreadComment]>- Replaces the default "Pinned" chip on a comment that has an anchor.
when(comment: ThreadComment) => string- Default
(comment) => shortDate(comment.createdAt, { locale }) - How a timestamp reads. Defaults to a short date.
whenEvent(event: ThreadEvent) => string- Default
(event) => shortDate(event.at, { locale }) - How an event's time reads. Defaults to a short date.
localestring- Default
"en-GB" - The locale the default times read in.
onPost(post: ThreadPost) => void | boolean | Promise<void | boolean>- Returns false to keep the draft. Without it no composer shows.
onEdit(comment: ThreadComment, body: string) => void | Promise<void>onDelete(comment: ThreadComment) => void | Promise<void>onResolve(comment: ThreadComment, resolved: boolean) => void | Promise<void>- Without it a root has no resolve button.
onAnchor(comment: ThreadComment) => void- A click on a pinned comment's chip, to move a canvas to its node.
canEdit(comment: ThreadComment) => boolean- Default
() => false - Whose comments carry the edit and delete buttons. A rich comment can't be edited here.
headingboolean- Default
true - False hides the visible title, for a thread already named by its tab. Screen readers still get it.
footerSnippet- Drawn above the composer, such as a question waiting on an answer.
classstring
| Prop | Type | Default |
|---|---|---|
comments required | ThreadComment[] | |
events Status moves, assignments and the like, one quiet line each between the comments. | ThreadEvent[] | [] |
loading Rows still on their way. Draws skeleton rows in place of the thread. | boolean | false |
labels | Partial<ThreadLabels> | |
avatar Replaces the default avatar for a person or an agent, drawn in a 24px slot. | Snippet<[ThreadComment]> | |
attachments Content under a comment's body, such as files. | Snippet<[ThreadComment]> | |
anchorChip Replaces the default "Pinned" chip on a comment that has an anchor. | Snippet<[ThreadComment]> | |
when How a timestamp reads. Defaults to a short date. | (comment: ThreadComment) => string | (comment) => shortDate(comment.createdAt, { locale }) |
whenEvent How an event's time reads. Defaults to a short date. | (event: ThreadEvent) => string | (event) => shortDate(event.at, { locale }) |
locale The locale the default times read in. | string | "en-GB" |
onPost Returns false to keep the draft. Without it no composer shows. | (post: ThreadPost) => void | boolean | Promise<void | boolean> | |
onEdit | (comment: ThreadComment, body: string) => void | Promise<void> | |
onDelete | (comment: ThreadComment) => void | Promise<void> | |
onResolve Without it a root has no resolve button. | (comment: ThreadComment, resolved: boolean) => void | Promise<void> | |
onAnchor A click on a pinned comment's chip, to move a canvas to its node. | (comment: ThreadComment) => void | |
canEdit Whose comments carry the edit and delete buttons. A rich comment can't be edited here. | (comment: ThreadComment) => boolean | () => false |
heading False hides the visible title, for a thread already named by its tab. Screen readers still get it. | boolean | true |
footer Drawn above the composer, such as a question waiting on an answer. | Snippet | |
class | string |