App components / AI chat
Composer
Where people write to the assistant: one card with the text, attachments and context above it, and the tools below. It moves through seven states (empty, typing, uploading, with attachments, with context, recording and generating) without changing shape.
Code
The component itself, ready to drop into your project. Switch between React, Vue and plain HTML; every version uses the same Tailwind classes on Ochre's tokens.
Try / or @, or type Summarise the launch plan in five bullets
Installation
Examples
Every state
Empty, typing, uploading, with attachments, with context, recording and generating.
Empty
Typing
Uploading
Attachments
Context
Recording
Generating
Motion
Built on Ochre's ease-out curves. With reduced motion switched on, everything still works, it just doesn't move.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| value / defaultValue / onValueChange | string | – | The text. |
| onSend | (text: string) => void | – | Enter or the send button. Shift+Enter adds a line. |
| completion | string | – | Ghost text after the caret; Tab accepts it. |
| attachments | ComposerAttachment[] | – | { id, kind, name, meta, progress, src }. Any uploading or fetching makes send wait. |
| onRemoveAttachment / onRetryAttachment / onOpenAttachment | (id: string) => void | – | Attachment actions. |
| context / onRemoveContext | ComposerContext[] | – | { id, kind, text, label, meta }: selections, replies, files, links. |
| onAttach / onFiles | (source) => void, (files: File[]) => void | – | A pick from the + menu; with onFiles, Upload a file and Add a photo open the file picker. |
| generating / onStop | boolean, () => void | – | The send button becomes Stop. |
| recording / onRecordStart / onRecordCancel / onRecordDone | boolean, () => void | – | Dictation with the mic: a waveform and a timer replace the text. |
| levels | number[] | – | Microphone levels 0 to 1, newest last. Simulated when left out. |
| onVoiceMode | () => void | – | The round voice button shown while the composer is empty. |
| webSearch / onWebSearchChange | boolean | – | The Web search toggle; orange while on. |
| effort / onEffortChange | EffortLevel | – | The Effort pill and slider. |
| model / onModelChange / models | string, ModelOption[] | "deep" | The model button and its menu. |
| commands / mentionables | SlashCommand[], Mentionable[] | – | What / and @ offer. |
| menuSide | "top" | "bottom" | "top" | Menus open above (at the foot of a chat) or below. |
Usage
Use it for
- The foot of every chat, and the middle of an empty one.
- Type / for commands and @ for files and people; the lists open without leaving the text.
- The effort pill, model and web search sit in the composer so people can change them per message.
Avoid
- A disabled send button when the composer is empty: it shows the round voice button instead.
- Blocking typing while an answer streams: people can write the follow-up and send it when it finishes.
- Sending while files upload: the button waits, greyed, and the message goes once they're in.