DocsDocs

Composer

The message field of a conversation, which grows with its text.

StableSince 1.0.0
On this page

Overview

Show code, AskAnything.tsx

Variants

Layouts

A composer is its field alone, or has a row below the field with controls at its start and the send button at its end, and a note under it.

Show code, StartAndFooter.tsx
Field alone

A chat or a prompt. The default.

With a start row

Attachments or a choice of model, beside the send button below.

Anatomy

  1. Composer

  2. Surface

  3. Input

  4. Start

  5. Send

  6. Footer

Show code, ComposerAnatomy.tsx

Behaviour

Pending send

While a send is in progress, the send button shows a spinner and the next send waits; the field keeps its text and height, stays editable and keeps focus.

Show code, PendingSend.tsx

Adapting to width

A composer fills its container, and its field grows with its text up to a set number of lines, then scrolls.

Show code, GrowingDraft.tsx

Rules

A composer stays ready for the next message, below the conversation it adds to.

Use it when

  • A message in a conversation, such as a chat, a comment or a prompt
  • A reply that runs after a send, which people may stop
DoWait while a send is in progress, so people can keep writing.
Show code, PendingStaysEditable.tsx
Donโ€™tA disabled composer, which takes focus away from the draft.
Show code, DisabledWhileSending.tsx

In a conversation

Place the composer below the conversation it adds to.

  • Show a message that couldn't be sent in the conversation, with its status.

Accessibility

KeyAction
Tab, Shift+TabMoves to the field, the start controls and the send button.
Enter in the fieldSends the message, unless it is blank, pending or running.
Shift+Enter in the fieldStarts a new line.
Enter, Space on the buttonSends the message, or stops the reply.