Composer
Composer is the box where people type a message and send it, as in a chat or a comment thread.
<Composer onSubmit={send}> <ComposerInput aria-label="Message" placeholder="Ask anything" /> <ComposerRow> <Button iconOnly aria-label="Add attachment">{icon}</Button> <ComposerSend status={status} icons={{ ready: sendIcon }} /> </ComposerRow></Composer>A Composer is the box people type a message into. It holds a text area that grows as you type, a row of controls under it, and a send button. Leave out ComposerRow and the controls share the text's line instead, as in a phone chat. Use it for an AI chat, a support inbox, a team thread or a comment field, which all share this shape. For one line of text in a form, use a TextField, and for a longer answer in a form, use a TextArea.
The Composer is a real <form>, and onSubmit runs when someone sends. Enter sends and Shift+Enter starts a new line, as in most chat apps. Enter doesn't send while someone is still composing Japanese, Chinese or Korean characters, and it doesn't send again while a request is running.
It looks like a Card, with the same fill, corner and shadow, because it holds full-size buttons rather than the small controls inside a text field. One size sets the padding, the corner, the text and every control in the row. A control that sets its own size keeps it.
ComposerSend changes meaning with status. ready sends, submitted shows a spinner, streaming turns it into a Stop button that calls onStop, and error turns it into Retry. It is the loud button by default. The package ships no icons, so pass your own with icons, and set labels to give each state an accessible name in your app's language.
The Composer doesn't show the conversation and doesn't keep files. Add your own attach button, and handle files that people drop or paste with onFiles. Use notices to show a Notice or a Confirmation above the box, and context for quiet facts below it, such as the model or how much context is left.
Set backdrop when content scrolls behind the Composer, so it uses the theme's material. ComposerInput needs an aria-label or aria-labelledby, because a placeholder isn't a name. The focus ring goes around the whole box while the text area has focus, but not when a button in the row has focus.
Topics
Every symbol this component exports, grouped by the job it does. Each one carries the props it declares; each one has an anchor of its own.
The box a message is typed into
Composer
Composer is the box where people type a message and send it, as in a chat or a comment thread.
| Prop | Type | What it does |
|---|---|---|
backdrop? | boolean | Set backdrop when content passes behind the composer, such as a scrolling conversation. |
context? | React.ReactNode | Short information about the conversation, such as the model or the remaining context. |
notices? | React.ReactNode | Messages that need attention before the next message, such as Notice and Confirmation. |
onFiles? | (files: File[]) => void | Called with the files that the user drops on the composer or pastes into the text. |
onSubmit? | (event: React.FormEvent<HTMLFormElement>) => void | Called when the user sends a message. |
size? | "1" | "2" | "3" | "4" | Sets the size step of the whole composer, from 1 to 4. |
It also takes every prop of a <form>.
ComposerInput
The text area where people type. It has no border of its own, because the Composer around it is already the box, and it needs an aria-label or aria-labelledby
| Prop | Type | What it does |
|---|---|---|
aria-label? | string | The name of the input for screen readers, such as Message. |
aria-labelledby? | string | The id of an element on the page that names this input. |
It also takes every prop of a <textarea>.
The controls under it
ComposerRow
The row of controls under the text. It sets their alignment and spacing, and a Flex inside it groups controls that belong together. Leave it out and the controls share the text's line
It declares no props of its own. It takes every prop of a <div>.
ComposerSend
The send button. Its status makes it send, show a spinner, stop a running request or retry a failed one
| Prop | Type | What it does |
|---|---|---|
icons? | Partial<Record<ComposerStatus, React.ReactNode>> | The icon for each status. |
labels? | Partial<Record<ComposerStatus, string>> | The accessible name for each status. |
onStop? | () => void | Called when the user presses the button while status is streaming. |
status? | "ready" | "submitted" | "streaming" | "error" | Sets what the request is doing, which changes what the button does. |
- The conversation — Messages, tool calls and reasoning each need a data model that belongs to your app. Build the conversation from
ScrollArea,CardandText, and keep the Composer for the input. - Keeping the conversation scrolled to the bottom — Keeping a chat pinned to the newest message while a reply streams in is a hard problem of its own. Use a dedicated library or your chat runtime for it.
- An attach button — Your app decides which files it accepts and how it uploads them, so add your own
Buttonwith your own icon. Files that people drop or paste still reachonFiles. - Holding the files — The Composer never stores files, previews or uploads, because your app owns them. Show each file with an
Attachmenttile, and set itsstatefrom your own upload code. - Named slots for the start and end of the row — Which controls go on the left and which go on the right depends on what they mean in your app. Put each group of controls in a
FlexinsideComposerRow. submitOnEnter— Enter always sends and Shift+Enter always adds a line, as in most chat apps, so there is nothing to switch. Enter never sends while someone is composing Japanese, Chinese or Korean characters.