The Composer component renders a message composer to create new threads and to reply to existing ones. The Composer is a complex component that can take a lot of props. To speed up development, we provide different components and hooks that allow you to customize the behavior to fit your needs, without having to worry about all of the Composer props.
There are two different components you can use:
SendComposer is used to send a new message to an existing thread. It can also be used to create a new thread.
EditComposer is used when you already have a message and would like to edit it.
An arbitrary string that uniquely identifies a thread. Messages sent will go to the provided thread ID. If the thread does not exist, then the createThread prop should be passed.
Warning! An important restriction of working with thread identifiers is that they must be unique across your entire application. You can't use the same thread identifier in two separate groups. This is an intentional limitation imposed by Cord.
An object containing the data of the thread to be created. If the thread specified in threadID exists, the message will be added to that thread and this object will be ignored.
Callback invoked before the message is sent. It receives the message data as an argument and should return the modified message data. If the callback returns null, the message will not be sent.
Callback invoked before the message is sent. It receives the message data as an argument and should return the modified message data. If the callback returns null, the message will not be sent.
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 composer. 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
ComposerLayout
Layout for the composer
TextEditor
Composer editor
SendButton
Button to send messages
ReactionPickButton
Button to add reactions
Button
Generic button component
ToolbarLayout
Composer toolbar layout. Contains "add attachment", "add emoji" and other buttons.
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-.
Class nameDescription
.cord-composer
Applied to the container div. This class is always present.
.cord-empty
Applied to the container div when the text editor is empty
.cord-valid
Applied to the container div when the message is valid and can be sent. This means there either some non-whitespace text, or at least one attachment.
.cord-always-expand
Applied to the container div, reflects the composer expanded prop.
.cord-never-expand
Applied to the container div, reflects the composer expanded prop.
.cord-auto-expand
Applied to the container div, reflects the composer expanded prop.
.cord-editor-container
Applied to the div containing the editor.
.cord-attachments
Applied to the div containing the attachments (files and images).
.cord-composer-error-message
Applied to the div containing the error message that appears when a message fails to send