Composer

Composer is a specialized text input component designed for composing messages in a chat interface.

Example

Basic Usage
A simple composer with default send button:
View code
Handling Messages
Use the onSend and onCancel props to handle user interactions:
View code
Loading State
When loading is true, the send button shows a progress indicator and can be used to cancel the operation:
View code
Custom Actions
Replace the default send button with custom left and right elements, the SendButton component is also available for customization.
View code
Size Control
Control the minimum and maximum rows for auto-resize, you can specify minRows and maxRows props to control the minimum and maximum rows for the default inputElement (which is Textarea). If you customize your own inputElement, you need to handle the minimum and maximum rows by yourself.
View code
Expanded State
By default the composer is collapsed, which place inputElement, leftElement and rightElement in the same row, it will react to user’s input and expand the composer when the input is more than 1 row. You can specify expanded prop to control the expanded state of the composer.
View code
Disabled State
Disable the entire composer when needed:
View code
Custom Color
Please use color and colorType props to customize the color of the composer.
View code
Integration with Mention
View code
Integration with Chat Interface
Here’s how Composer integrates with a complete chat interface:
View code

Relevant components

API

SendButton
Prop nameTypeDefaultDescription
asany
Tag or component, but a simple tag (i.e. built-in components, e.g. div, span) is recommended.
colorTypeColorTypes
Set color based on theme. If color is specified, that prop is used instead of this.
disabledboolean
Equivalent to button's disabled property.
keyboardClickKeysstring[]
loadingboolean
onBlurFocusEventHandler<HTMLDivElement>
onClickMouseEventHandler<HTMLDivElement>
onKeyDownKeyboardEventHandler<HTMLDivElement>
onKeyUpKeyboardEventHandler<HTMLDivElement>
onMouseDownMouseEventHandler<HTMLDivElement>
onMouseLeaveMouseEventHandler<HTMLDivElement>
onMouseUpMouseEventHandler<HTMLDivElement>
onReleaseEventHandler<SyntheticEvent<HTMLDivElement, Event>>
Callback that's triggered after click i.e. mouseup and keyup of enter or space.
onTouchEndTouchEventHandler<HTMLDivElement>
onTouchStartTouchEventHandler<HTMLDivElement>
progressCirclePropsProgressCircleProps
radiusstring
sizeIconButtonSizessmall
tooltipReactNode
tooltipPropsOmit<TooltipProps, "title" | "children">
variantIconButtonVariants
    Example
    Example
    Basic Usage
    Basic Usage
    Handling Messages
    Handling Messages
    Loading State
    Loading State
    Custom Actions
    Custom Actions
    Size Control
    Size Control
    Expanded State
    Expanded State
    Disabled State
    Disabled State
    Custom Color
    Custom Color
    Integration with Mention
    Integration with Mention
    Integration with Chat Interface
    Integration with Chat Interface
    Relevant components
    Relevant components
    API
    API
    SendButton
    SendButton
Coral is a thoroughly developed design system widely adopted by developers and designers for creating beautiful and user-friendly Sea internal products.

Copyright © 2018-2025 Sea Labs