Skip to content
English

Usage

import { ChatComposer } from './ChatComposer.jsx'

// Resolves when the answer has been written; a rejection puts the message back in the box.
const send = ({ text, files, mode }) => fetch('/api/chat', { method: 'POST', body: JSON.stringify({ text, files: files.map((file) => file.name), mode }) })
const upload = (file) => fetch('/api/files', { method: 'POST', body: file })

export function TripComposer() {
  return <ChatComposer locale="en" attachments={[]} onSend={send} onAttach={upload} />
}

Props

PropTypeDefaultWhat it does
locale'en' | 'zh-CN' | 'es' | 'ja''en'Language of the built-in text, the ideas and the file sizes.
ideas{ icon, title, text }[]sampleWays to start, shown while the box is empty. Choosing one puts its text in the box to finish.
attachments{ id, name, size }[]sampleFiles already attached when the box opens.
modes{ key, label, icon }[]sampleAnswer modes in the picker beside the clip. With one mode the picker is hidden.
defaultModestringfirst modeThe mode chosen at first.
maxLengthnumber2000Longest message. The count appears from 80% of it.
onSend({ text, files, mode }) => Promise—Sends the message. Stop shows until it resolves; a rejection puts the message back with Try again.
onStop() => void—Called when the visitor stops the answer (the stop button or Escape).
onAttach(file: File) => Promise—Uploads one file. Its chip shows the upload until it resolves. Files over 20 MB are refused in place.
onModeChange(key) => void—Called when another answer mode is chosen.
generatingbooleanfalseOpens with a message already sent and its answer being written, so stop is showing.
errorbooleanfalseOpens with a message that could not be sent, still in the box, and Try again.
labelsobject—Replaces any built-in text (see copy.js), such as placeholder, send, stop or remove.
classNamestring—Added to the root; other attributes go there too.

Add it to your project

Copy the prompt into Codex or Claude Code. The agent reads the published source, shows you what it will write and adds the block together with the components it is built from.

ChatComposer.jsxchat-composer.csscopy.jskit.jsxkit.cssui/base-button/ui/textarea/ui/agent-status/ui/dropdown-menu/tokens.cssREADME.md

The block, its stylesheet and text, the shared kit, the components it uses and tokens.css install together into one folder.