chatcn

Composer

The ChatComposer component provides a full-featured message input with auto-resize, attachment menu, reply preview, and keyboard shortcuts.

Live Demo

Try typing a message and pressing Enter to send. Right-click a message to reply to it.

Today
A
Alex

Try typing a message below!

Basic Usage

At minimum, provide an onSend callback. The composer handles the input state internally.

Attachment Menu

The composer includes a + button that opens a popout menu for attachments. Click it in the demo above to see it in action.

Drag & Drop

The composer has built-in drag-and-drop support. Drag any file over the input area and a drop overlay appears. Dropped files render as removable previews (with thumbnails for images) before the message is sent. This works alongside the + button menu and clipboard paste.

Reply Mode

When replying to a message, the composer shows a preview of the quoted message above the input. The user can dismiss the reply with the X button.

AlexShould we migrate to the new API version?

Auto-Resize

The textarea automatically grows as you type multi-line messages, up to a configurable max height. This behavior is built-in and requires no additional configuration.

Props

PropTypeDescription
onSend(text: string) => voidCalled when user sends a message
replyingToChatMessageData | nullMessage being replied to (shows preview)
onCancelReply() => voidCalled when reply is dismissed
onFileUpload(files: File[]) => voidCalled when files are selected or dropped
onTyping(isTyping: boolean) => voidCalled when typing state changes
placeholderstringInput placeholder text (default: 'Type a message...')
onVoiceRecord() => voidCalled when mic button is clicked (shows mic icon when composer is empty)
disabledbooleanDisable the composer