Display conversations anywhere in your product


This component is in development; interface and features are subject to change prior to final release.

Visit the Replacements API step by step guide.

When to use #

The Thread component renders a single conversation thread, or a message composer to create a new thread. Threads contain everything your users need to have a conversation.

This component pairs well with:


How to use #

React:
import { betaV2, thread } from "@cord-sdk/react";
  
  function ExampleThread({threadID}) {
    const threadData = thread.useThread(threadID);
    // If you need to modify some info from your thread, this is the place to do it

    return <betaV2.Thread
      thread={threadData}
      showHeader
      style={{
        // Recommended so that long threads scroll instead 
        //of disappearing off-screen
        maxHeight: "400px", 
        // Recommended so that threads don't stretch horizontally 
        // based on their content
        width: "300px",
      }}
    />;
  }
import { betaV2, thread } from "@cord-sdk/react";
  
  function ExampleThread({threadID}) {
    const threadData = thread.useThread(threadID);
    // If you need to modify some info from your thread, this is the place to do it

    return <betaV2.Thread
      thread={threadData}
      showHeader
      style={{
        // Recommended so that long threads scroll instead 
        //of disappearing off-screen
        maxHeight: "400px", 
        // Recommended so that threads don't stretch horizontally 
        // based on their content
        width: "300px",
      }}
    />;
  }
Copy

Alternatively, you can use Thread.ByID to render a thread given its ID. We'll do the data fetching for you.

React:
import { betaV2 } from "@cord-sdk/react";
import NextUp from 'docs/server/ui/nextUp/NextUp.tsx';
import NextUpCard from 'docs/server/ui/nextUp/NextUpCard.tsx';

function ExampleThread({threadID}) => {
  return (
    <betaV2.Thread.ByID
      threadID={threadID}
    />
  );
};
import { betaV2 } from "@cord-sdk/react";
import NextUp from 'docs/server/ui/nextUp/NextUp.tsx';
import NextUpCard from 'docs/server/ui/nextUp/NextUpCard.tsx';

function ExampleThread({threadID}) => {
  return (
    <betaV2.Thread.ByID
      threadID={threadID}
    />
  );
};
Copy

View Source Code


Properties #

<Thread> #


threadData #

required
ClientThreadData
The data of the thread to be displayed.

This is an object with the following fields:

Show property details



showHeader #

optional
boolean
If set to true, the header of the thread will be displayed. Defaults to false.


composerExpanded #

optional
"auto" | "never" | "always"


style #

optional
CSSProperties
Passes the style of the component. It will be applied to the root element.


className #

optional
string
Any classes to be added to the component. It will be applied to the root element.


replace #

optional
ReplaceConfig
Object that contains the components that will be replaced in the thread. Find more information about it here.

<Thread.ByID> #


threadID #

required
string
The ID of the thread to be displayed.


createThread #

optional
ClientCreateThread
An object containing the data of the thread to be created. If the thread already exists, this will be ignored.

This is an object with the following fields:

Show property details



showHeader #

optional
boolean
If set to true, the header of the thread will be displayed. Defaults to false.


composerExpanded #

optional
"auto" | "never" | "always"


style #

optional
CSSProperties
Passes the style of the component. It will be applied to the root element.


className #

optional
string
Any classes to be added to the component. It will be applied to the root element.


replace #

optional
ReplaceConfig
Object that contains the components that will be replaced in the thread. Find more information about it here.

Customization with Replacements #

If you want to customize your component, you can customize the CSS (see below), but you can also switch parts of the component for your own ones with out Replacements API.

These are the components you can replace in the message. Some are better understood in context. We suggest inspecting the component with your browser's developer tools to find elements with a data-cord-replace attribute.

ComponentDescription
ThreadLayout
The container with all the elements related to a thread.
Message
Each one of the messages in the thread.
Composer
The composer to send a message.
Header
The header of the thread.
ThreadSeenBy
The list of users who have seen the thread.

If you want to customize the composer, please refer to the section on customizing the <Composer/>. If you want to customize the messages shown, see the details in <Message/>.


CSS customization #

If you want to customize this component, you can target some classes with the cord- prefix in your app's CSS. These are guaranteed to be stable.

These classes 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 the prefix cord-.



Not finding the answer you need? Ask our Developer Community

Ask Cordy