Skip to content

Chat Composer

The input of an agent: write, attach, pick a model and how much it may do on its own, connect apps - then send.

On this page
Used for
  • Prompt box for agents
  • Attach files to a prompt
  • Pick a model
  • Set permission mode
  • Dictate a message

Examples

Width

Installation

npx knowns-ui@latest add chat-composer
For Claude Code, Cursor or Codex: installs it and wires the props to your own data.

Props

onSubmit
(message: ComposerMessage) => void
Enter or the send button. Gets { text, model, mode, attachments, apps, folder }; clears the text and attachments after.
value / defaultValue / onValueChange
string / string / (v) => void
Default""
The text, controlled or not.
placeholder
string
Default"Ask anything…"
Shown while empty.
busy / onStop
boolean / () => void
Defaultfalse
While busy the send button becomes Stop and a light band travels around the card border, fading in and out with the state. Reduced motion shows a still accent ring. Tint it with --kn-accent.
models
ComposerModel[]
Defaultbuilt-in list
{ id, name, detail?, icon? }. Without an icon, the provider logo is picked from the name.
model / defaultModel / onModelChange
string / string / (id) => void
Defaultfirst model
The chosen model.
mode / defaultMode / onModeChange
"ask" | "auto" | "full"
Default"ask"
How much the agent may do on its own: Ask before acting, Auto-approve safe actions, Full access.
attachments / onAttachmentsChange
ComposerAttachment[] / (a) => void
Default[]
{ id, name, kind?, size?, progress? } shown as removable tiles above the text. Tiles land one by one; progress (0 to 1) fills a thin bar until it reaches 1.
onAttach
(kind: "file" | "image" | "folder" | "link") => void
The + menu: Upload a file, Add an image, Attach a folder, Paste a link. Open your picker and add the result to attachments.
apps
ComposerApp[]
Defaultbuilt-in list
{ id, name, icon? } the agent can be connected to. Without an icon, the brand logo is picked from the name. [] hides the apps menu.
connectedApps / defaultConnectedApps / onConnectedAppsChange
string[] / string[] / (ids) => void
Default["chat"]
Ids of the apps that are on.
folders
string[]
Defaultbuilt-in list
Working folders offered in the bottom row. [] hides the folder picker.
folder / defaultFolder / onFolderChange
string | null / string | null / (f) => void
Defaultnull
The working folder; null is none.
dictation
{ listening, transcript?, onToggle }
Shows the mic. You run speech recognition; the live transcript is shown while listening.
footer
ReactNode | false
Replace the bottom row, or false to hide it.
maxRows
number
Default8
The text area grows up to this many rows, then scrolls.
disabled
boolean
Defaultfalse
Disables the whole composer.
className
string
On the outer element.

Keyboard

KeysWhereDoes
EnterTextSend.
ShiftEnterTextNew line.
⌘ / CtrlEnterTextSend.
EnterSpace↓Menu buttonOpen the menu and focus its first item.
↑↓HomeEndOpen menuMove between items.
EscAnywhereClose the open menu, or stop dictation.

Accessibility

The text area has a label, and every icon button has a name and a tooltip. The +, mode and apps buttons open menus, the model and folder buttons open single-choice lists; each reports whether it is open. They move focus with the arrow keys and give it back to their button when they close. Attachment chips have a remove button named after the file. While busy, the send button becomes a Stop button with its own name, and the mic button is pressed while listening.

What it handles

  1. 01Grows the textarea with its text up to maxRows, 8 by default, and then scrolls inside it.
  2. 02Sends on Enter and breaks the line on Shift+Enter, ignores Enter while an input method is composing, then clears the text and attachments.
  3. 03Turns the send button into Stop while busy is true and calls onStop, and draws a travelling light around the border while the agent works.
  4. 04Adds attachment tiles of file, image, folder or link kind with size and an upload bar that fills to 1, and removing one collapses it.
  5. 05Offers a model picker, an ask, auto or full permission mode, connected apps and a working folder, each as a controlled or uncontrolled value.
  6. 06Takes dictation from your own state, shows the transcript muted under the text, and stops listening on Escape.

States

First render
Nothing. It paints as it is
none
Agent starts working
A light fades in around the card border
280ms, ease out
Agent stops
The light fades out
180ms, ease out
Attachment added
The tile rises in, up to 4 steps of 40ms apart
180ms, ease out
Attachment removed
The tile collapses and fades
120ms, ease out
Upload progress
The bar along the tile fills
280ms, ease out
Mode or send label changes
The new label fades in
180ms, ease out
Reduced motion
Light, tiles and labels change at once
0ms

Works with

When to use

When to use

  • The input for an agent: autosizing text, attachments, model and permission menus, dictation, send and stop.
  • Any screen where the user writes a prompt that may run for a while and needs a stop button.

When not to use

  • A plain single-line search or form field: use Input.
  • Picking a model on its own, outside the composer: use Model Picker.
  • Saved prompts with blanks to fill in: use Prompt Templates.

Using with AI

Use Copy page for AI above to give your assistant this page, Copy prompt under the install command to have it installed and wired to your data, or connect the Knowns UI MCP server and just ask:

  • Add the Knowns UI Chat Composer to my app and wire it to my own data.
  • I need the input for an agent: autosizing text, attachments, model and permission menus, dictation, send and stop. Set that up with the Knowns UI Chat Composer.
  • Which Chat Composer props do I need for a minimal setup? Show me a short example.

With the server connected, your assistant calls get_component({ name: "chat-composer" }) and search_docs({ query: "chat composer" }).

Need help?

Stuck on Chat Composer, or found something off? We read every message.