Chat message
One message in a conversation, between people or with an assistant: avatar, author and time, a bubble that keeps line breaks, attachments, the delivery status of what you sent, and actions on hover. It also draws the typing dots and a caret for text that is still streaming in. For a feed of events, use the activity feed.
Install
npx shadcn@latest add @thrum-pro/chat-messageThis is a Pro component. The command works once your project has a licence key: set up Pro or see pricing.
Automatically installs icons check, circle-alert, clock and file from the icon set.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
ChatMessage: side | "incoming" | "outgoing" | "system" | Default "incoming" | Who sent it. incoming sits on the start side in the muted colour, outgoing on the end side in the primary colour, system is a centred note with no bubble. |
ChatMessage: ...props | ComponentProps<"article"> | – | Every other article attribute is passed through. className is merged last. |
ChatMessageAvatar | ComponentProps<"div"> | – | Holds an Avatar at the top of the message. Leave it out for a run of messages from one sender and indent with ps-10. |
ChatMessageContent | ComponentProps<"div"> | – | The column beside the avatar, at most 80% of the row wide, aligned to the sender's side. |
ChatMessageHeader | ComponentProps<"div"> | – | The row above the bubble for the author and the time. |
ChatMessageAuthor | ComponentProps<"span"> | – | The sender's name, medium weight, cut short with an ellipsis when it does not fit. |
ChatMessageTime: dateTime | Date | string | Required | When it was sent. Written into the datetime attribute and, with no children, printed as hours and minutes. |
ChatMessageTime: locale | string | Default "en-US" | The locale of the printed time. |
ChatMessageTime: timeZone | string | – | The time zone of the printed time. Set it when the page renders on a server, so the server and the browser print the same. |
ChatMessageBubble: streaming | boolean | Default false | Show a caret after the text while it is still being written. |
ChatMessageBubble: typing | boolean | Default false | Show three dots instead of text: the sender is typing. |
ChatMessageBubble: typingLabel | string | Default "Typing" | What a screen reader hears for the dots: "Mira is typing". |
ChatMessageBubble: paused | boolean | Default false | Freeze the typing dots where they are. |
ChatMessageAttachments | ComponentProps<"div"> | – | A wrapping row for files and images sent with the message. |
ChatMessageFile: name | string | Required | The file name. A long name is cut short with an ellipsis; the full name stays in the link's name and its tooltip. |
ChatMessageFile: detail | string | – | Its size or type, after the name: "48 KB". |
ChatMessageFile: href | string | – | Where the file opens. Without it the chip is plain text, not a link. |
ChatMessageStatus: status | "sending" | "sent" | "failed" | Required | Where an outgoing message is. Each has a word and a glyph: a clock, a tick, a circled exclamation mark. |
ChatMessageStatus: onRetry | () => void | – | Shows a Retry button beside a failed status, and is called when it is pressed. |
ChatMessageStatus: labels | { sending?, sent?, failed?, retry? } | – | Replaces the words Sending, Sent, Not sent and Retry. |
ChatMessageActions | ComponentProps<"div"> | – | Buttons for the message: copy, retry, a reaction. Shown on hover and while the focus is inside the message, and always on touch screens. |
Motion and sound
Motion
- The typing dots rise and fade one after another, once every 1.2 seconds. paused freezes them.
- The action row fades in over 150 ms when the pointer enters the message or the focus moves into it.
- Reduced motion: the dots stand still and the actions appear at once.
Sound
Silent. This component makes no sound.
Accessibility
- Each message is an article. Put the conversation in an element with role="log" and a name, so a screen reader reads new messages as they arrive.
- The time is a time element with a machine-readable datetime.
- The delivery status is a word as well as a glyph, in a status region, so a failure is announced. The failed status uses the destructive colour.
- The typing dots are hidden from screen readers; typingLabel is read in their place, as a status.
- Line breaks are kept, and long words and links break anywhere, so nothing overflows the bubble at 160 pixels wide.
- Outgoing text is the primary foreground on the primary colour and incoming text the foreground on the muted colour: both keep 4.5 to 1.
| Keys | Action |
|---|---|
| Tab | Move through the links and buttons of each message: file, Retry, then the actions, which appear as the focus arrives. |
| Enter / Space | Press the focused button, or open the focused file. |
Source
The source comes with Pro
TypeScript source · Copy-paste ready · MIT-compatible for client projects · Includes all dependencies
Files and dependencies
- Adds
components/ui/chat-message.tsx- Packages
- None
- Brings along
- Button
- Icons
checkcircle-alertclockfile
Changelog
- 1.0.0 · 2026-12-03First release.