Composer field

Free

The chat box of an AI agent: files, your words, tools, the model with its effort, dictation and send, with folder, branch and permission below. Messages sent while it works wait in order.

npx shadcn@latest add https://pixilui.com/r/composer-field.json

Preview

Keep typing while the agent works: messages wait in order, and Stop puts them back.
Notices

When to use

Use it when

  • The box of a chat with an agent that works in steps: <ComposerFieldChat> for the thread and the queue, or <ComposerField> alone under your own thread.
  • Pick the model and its effort, turn tools on, attach files, mention files with @ and run commands with /.
  • Say where the agent works (folder, branch) and what it may do (ask, auto-approve edits, read only).

Use something else when

  • A plain search or a one-line field: use the search field or the input.
  • A box that only sends and stops: use the prompt input.

Installation

Terminal
npx shadcn@latest add https://pixilui.com/r/composer-field.json

Adds composer-field.tsx with button.tsx, chip.tsx, dropdown-menu.tsx, text-shimmer.tsx, kbd.tsx, tooltip.tsx, meter.tsx and usage-meter.tsx, and installs clsx and tailwind-merge. The URL works in any app with a components.json, with no registry to add first.

Usage

example.tsx
import { ComposerField } from "@/components/pixilui/composer-field";

<ComposerField
  icons={icons}
  onChange={onChange}
  onSubmit={onSubmit}
/>

Fills its container and follows its own width (container queries): the effort word, then the branch, then the folder step aside as it narrows.

API reference

PropTypeDefault
iconsRequiredComposerIcons–The icons it draws.
status"submitted" | "streaming" | "ready" | "error""ready"The chat's status: submitted or streaming is the agent at work (send becomes Stop, or Queue once you type).
defaultValuestring""Words in the field at first.
onChange(text: string) => void–Runs as the words change.
onSubmit(draft: ComposerMessageDraft) => void | boolean | Promise<void>–Runs on Enter or Send with what to send; the field then clears. Return false to keep the words in the box (the model is busy).
onStop() => void–Runs on Stop (or Escape) while the agent works.
onEditLast() => void–Runs on Up in an empty field: edit your last message.

Also takes every native <div> attribute, and a ref.

Keyboard

EnterSends, or queues while the agent works (never in the middle of composing Japanese or Chinese).
⇧ EnterAdds a line.
/ @Open the typed menus at the caret; Up and Down move, Enter or Tab picks, Escape closes.
↑In an empty field, edits your last message.
EscStops the agent, or cancels dictation.
⌘ KFocuses the field.
← →In the model menu, change the effort (Home and End on the ramp).

Accessibility

  • The field is a textbox (aria-multiline) described as "Enter sends. Shift Enter adds a line. Slash opens commands, at mentions a file."
  • Send stays focusable when it can't send: aria-disabled with its reason as the tooltip (Type a message to send, Too long to send, Sends when the uploads finish).
  • Every icon button has a name and its tooltip shows its key; menus are the locked dropdown's (roles, aria-activedescendant, switch rows).
  • The effort ramp is a slider with aria-valuetext; the approval card is a group named "The agent is waiting for your approval".
  • A polite live region says what happened: Queued, Stopped and the messages back in the box, Copied, Back online.

Motion

  • Send: your words fly from the field into their bubble (380ms, an ease-in-out cubic that follows a target that can move) while it fills in.
  • The first message glides the box from the middle to the bottom (560ms).
  • Stop with waiting messages: they fly back into the box, lowest first, 80ms apart, each 420ms, their rows folding; send stays off until they land.
  • A white sheen sweeps across send once as a message leaves; the arrow lifts when send turns on.
  • Effort: the light sweeps bar by bar to the new stop (12ms a bar), the lit bars breathe faster the harder it thinks, Max adds a glint; the cost line swaps with a blur.
  • Notices, quote, files and the count open as grid rows (260ms); file tiles arrive, fill their ring and resolve into a check.
  • The approval card arrives with a soft glow in the waiting color (1500ms).
  • Reduced motion: everything lands at once.
Prompt inputGrows with the text, sends on Enter, and Send turns into Stop while the model answers.
Thinking stateSays what the agent is doing with a live timer, then folds to Worked for 14s.
Dropdown menuA highlight glides between rows, and each row's icon plays as it lands.

PixilUI Pro opens soon. The first 20 licenses are $99.