Put messages wherever you want. Don't worry, we'll handle reactions, as well as deleted, editing and unread states for you!
The <Message />
component renders a fully baked message. It gives your users an intuitive commenting UI that matches the experience of using a well-crafted chat in tools like Slack or Figma. You don't have to worry about how users add reactions, how they edit a message, how they delete one, or whether it is seen or unseen by the current user. We've got you covered! It will even handle timestamps that update live on the page while you're chatting.
This component starts you off with a 10/10 of message experience that you can customize as you need.
You can change the background and even the structure of the component. We built the component using grid-template-areas
, so feel free to inspect the example message above and play around with the grid-area
.
Do you want to build a chat? Maybe Slack-like threads? Or even a thread preview? Pair this component with our Thread API to access the data you need and create the experiences you want! Specifically, check out the get threads API and the get thread API to fetch relevant thread IDs and message IDs for a particular location or thread respectively.
Looking for the message data format?
Check out the how-to guide for examples of the Cord message data format
import { Message } from "@cord-sdk/react";
export const Example = () => (
<Message
threadId={'my-awesome-thread-id'}
messageId={'my-awesome-message-id'}
onMessageClick={({threadID, messageID}) =>
console.log("user clicked on message:", messageID, threadID)
}
/>
);
If true
, then this message and its containing thread will automatically be marked as seen when they have been visible in the browser for about one second. If false
, this behavior is disabled.
The default is true
.
If true
, then this message component will render a Composer that can be used to edit the message content. This can be used together with the onMessageEditEnd
callback to create a custom edit button instead of the default one in message options.
The default is false
.
{threadId: string; messageId: string; thread: ThreadSummary; message: ClientMessageData}
containing information about the message which was clicked as an argument.onRender
to determine when loading is complete.onLoading
to determine when a component begins loading.{threadId: string; messageId: string; thread: ThreadSummary; message: ClientMessageData}
containing information about the hovered message.{threadId: string; messageId: string; thread: ThreadSummary; message: ClientMessageData}
containing information about the hovered message.{threadId: string; messageId: string; thread: ThreadSummary; message: ClientMessageData}
containing information about the message being edited.onEditEnd
to determine when editing is complete.{threadId: string; messageId: string; thread: ThreadSummary; message: ClientMessageData}
containing information about the message being edited.onEditStart
to determine when editing begins.{thread: ThreadSummary}
containing the summary of the thread being resolved.{thread: ThreadSummary}
containing the summary of the thread being reopened.If you want to customize this component, you can target the classes below in your app's CSS. These are guaranteed to be stable.
There are more classes that are best understood in context. We suggest inspecting the component with your browser's developer tools to view everything. You can target any classes starting with cord-
.
We add any classes present in the message's extraClassnames
field.
You can combine this field and CSS for achieving greater customization. This allow you to make messages look different from each others.
.cord-message
grid-template-areas
to modify the layout of the message..cord-author-name
.cord-message-content
.cord-options-menu-trigger
.cord-sent-via-icon
.cord-deleted-icon
.cord-deleted-message-text
.cord-undo-delete-button
Not finding the answer you need? Ask our Developer Community