Prompt bar

A React component in Beamline's AI & agents category.

The agent composer: a field that grows, @ to add a source, / for a command, a model picker, files and dictation, and one button that sends with progress and becomes Stop while the answer arrives; a refused send keeps the draft and says why.

Use it for

  • The main composer of an agent or copilot: sources to read, a command, a model, files, dictation.
  • Any chat with an agent where sending can be refused (quota, permissions) and the draft must survive.

Not for

  • People chatting with people: receipts and reactions (chat-thread has its own composer).
  • @mentions of teammates in comments (mention-input).
  • Plain multi-line text in a form (textarea).

Anatomy

  • frame (one rounded surface; focus ring on the frame)
  • context row: command chip, source chips, attachments; it keeps to two lines: sources beyond fold into "+N" (order kept; the command and the files always show), which shows them all until the message is sent
  • multiline textbox with list autocomplete, controls and active-descendant links (grows to 200px, lg 280px; long unbroken text such as a URL wraps inside it)
  • + menu (Upload files, Sources as checks)
  • model picker (ModelPicker, ghost: the shared model list with its facts and filters)
  • mic (dictation)
  • Send / Stop
  • suggestion list above the frame in a named region (Sources or Commands), including its portalled heading and result status
  • error or hint line
  • room: under 28rem of its own width the field takes its own row and the controls sit under it

Variants

  • size: md (one row that grows; under 26rem of its own width the field takes the full first row and +, model and Send move to a row below), lg (hero: taller field, controls on their own row)

States

  • empty (Send disabled)
  • typing
  • suggesting (@ or /)
  • submitting (Send shows progress, field read-only)
  • streaming (Stop)
  • refused (error line, field invalid, draft kept)
  • listening (mic on)
  • uploading (Send waits for files)
  • disabled
  • Send disabled without onSubmit/onSend; synchronous refusal preserves draft

Keyboard

  • Enter sends; Shift+Enter starts a new line; IME composition never sends
  • @ (anywhere after a space) opens Sources, / at the start opens Commands
  • ↑ ↓ move in the list, Enter or Tab picks, Escape closes it and keeps the text
  • Backspace at the very start removes the command chip, then the newest source chip
  • Tab reaches +, model, mic and Send; the suggestion list never takes focus (aria-activedescendant)

Motion

The frame's focus ring is instant; the list opens in --pui-motion-in and leaves in --pui-motion-out; chips and files grow in, slide along and leave a fading ghost (useFlip); Send fills as the look's solid once there is something to send, and its glyph fades to Stop and back; a refusal rises in under the bar; the mic pulses only while listening (stopped under reduced motion).

Props

PropTypeDefaultDescription
value / defaultValue / onValueChangestring—value: The draft, controlled or not. defaultValue: Initial prompt text when uncontrolled. Defaults to an empty string. onValueChange: Reports prompt text after an edit; no callback by default.
onSubmit(message: PromptSubmission) => void | Promise<unknown>—Sends the message. Return a promise: the bar shows it is sending, clears on success, and keeps the draft with the reason when it is refused.
onSend(text: string) => void—Legacy text-only submit observer; omitted by default and still called alongside onSubmit when both are supplied. Deprecated: use onSubmit; still called with the text.
streaming / onStopboolean / () => void—streaming: The answer is still arriving: Send becomes Stop, and Enter keeps the draft instead of sending. onStop: Stops the active operation; no handler by default.
loadingboolean—Sending is in progress elsewhere (you manage it yourself): the send button shows progress, the draft stays.
sources / selectedSources / defaultSelectedSources / onSelectedSourcesChangePromptSource[] / string[]—sources: The @ list and the + menu's sources. selectedSources: Controlled source ids included in the next answer; omit to use defaultSelectedSources. defaultSelectedSources: Initial selected source ids when uncontrolled. Defaults to an empty list. onSelectedSourcesChange: Reports selected source ids after a change; no callback by default.
commandsPromptCommand[]—The / list. One command applies to a message.
models / model / defaultModel / onModelChangePromptModel[] / string—models: Model choices offered by the composer. Defaults to an empty list. model: The chosen model's id; defaults to the first model. defaultModel: Initial selected model id; defaults to the first supplied model. onModelChange: Reports model id after a change; no callback by default.
attachments / onAttach / onAttachmentRemove / onAttachmentRetry / acceptAttachmentFile[] / (files: File[]) => void—attachments: Files attached to the draft, with their upload state (you upload; see Attachment). onAttach: Files the person picked; shows "Upload files" in the + menu. onAttachmentRemove: Removes the attachment with the supplied id; no handler by default. onAttachmentRetry: Retries uploading the failed attachment; no handler by default. accept: File types offered, as for `<input accept>`.
listening / onListeningChangeboolean—listening: Dictation: true while your speech-to-text is listening; stream its words into `value`. Shows the mic when onListeningChange is set. onListeningChange: Reports listening state after a change; no callback by default.
size"md" | "lg"—md: one row that grows; lg: hero sizing with the controls on their own row.
placeholder / label / hint / error / disabledstring / ReactNode / boolean—placeholder: Text shown before a value is entered or selected. Defaults to "Ask anything". label: Accessible name of the text field. Default "Prompt". hint: A quiet line under the bar: a shortcut reminder, a disclaimer. error: A refusal from outside (quota, offline); shown under the bar. disabled: Prevents interaction with the control. Defaults to false.
classNamesPromptBarClassNames—Classes for the named visual parts; no part overrides by default.
style / refCSSProperties / native Ref (RichTextEditor retains imperative handle)—style: Inline styles on the documented visual root; no inline overrides by default. ref: Receives the documented root element; no ref by default.
fieldRefRef<HTMLTextAreaElement>—Receives the native field; no ref by default.
styleCSSProperties—Inline styles on the documented visual root; no inline overrides by default.
valuestring—The draft, controlled or not.
defaultValuestring—Initial prompt text when uncontrolled. Defaults to an empty string.
onValueChange((value: string) => void)—Reports prompt text after an edit; no callback by default.
streamingboolean—The answer is still arriving: Send becomes Stop, and Enter keeps the draft instead of sending.
onStop(() => void)—Stops the active operation; no handler by default.
sourcesPromptSource[]—The @ list and the + menu's sources.
selectedSourcesstring[]—Controlled source ids included in the next answer; omit to use defaultSelectedSources.
defaultSelectedSourcesstring[]—Initial selected source ids when uncontrolled. Defaults to an empty list.
onSelectedSourcesChange((ids: string[]) => void)—Reports selected source ids after a change; no callback by default.
modelsPromptModel[]—Model choices offered by the composer. Defaults to an empty list.
modelstring—The chosen model's id; defaults to the first model.
defaultModelstring—Initial selected model id; defaults to the first supplied model.
onModelChange((id: string) => void)—Reports model id after a change; no callback by default.
attachmentsAttachmentFile[]—Files attached to the draft, with their upload state (you upload; see Attachment).
onAttach((files: File[]) => void)—Files the person picked; shows "Upload files" in the + menu.
onAttachmentRemove((id: string) => void)—Removes the attachment with the supplied id; no handler by default.
onAttachmentRetry((id: string) => void)—Retries uploading the failed attachment; no handler by default.
acceptstring—File types offered, as for `<input accept>`.
listeningboolean—Dictation: true while your speech-to-text is listening; stream its words into `value`. Shows the mic when onListeningChange is set.
onListeningChange((listening: boolean) => void)—Reports listening state after a change; no callback by default.
tallboolean—Legacy height choice; omitted by default. Use size=lg instead. Deprecated: use size="lg".
placeholderstring—Text shown before a value is entered or selected. Defaults to "Ask anything".
labelstring—Accessible name of the text field. Default "Prompt".
errorReactNode—A refusal from outside (quota, offline); shown under the bar.
hintReactNode—A quiet line under the bar: a shortcut reminder, a disclaimer.
disabledboolean—Prevents interaction with the control. Defaults to false.
classNamestring—Classes on the documented visual root; no override by default.
refRef<HTMLDivElement>—Receives the documented root element; no ref by default.

Built from

Used in

Dependencies

lucide-react, radix-ui

Import

import { PromptBar } from "@beamline/prompt-bar";

Get it

Prompt bar is part of Beamline UI. Install the parts you need in your React app as compiled packages or editable source. Get Beamline · Connect your agent

More in AI & agents

  • Image generation: The frame an AI image is generated into: a field of brand-hued pixels breathes with the progress while the model works, then the image arrives —…
  • Flowchart: A workflow as steps on a dotted canvas: a trigger, conditions that branch into paths side by side, actions and waits, read top to bottom; during a run…
  • Run trace: One agent run as a waterfall: every step (model calls, tools, retrieval, checks, sub-agents) nested under the step that started it, each a bar on a…
  • Run theatre: One agent run as a theatre: the Run trace's waterfall under a transport (play, scrub, speed) that replays the run as it happened. Pick a step and re-run…
  • Answer compare: Two answers to the same prompt side by side, and a person's verdict: A is better, a tie, B is better, or both are bad, with the reasons that decided it…
  • Branch navigator: The versions of an assistant conversation that forked when a message was edited or an answer regenerated: a “‹ 2 / 3 ›” switch on each message that has…
  • Response: An assistant's answer as streamed markdown in the system's reading type: bursty tokens flow in at an even pace, each new word fades in through a short…
  • Chat thread: People talking to people: messages grouped by person and day, reactions, delivery and read receipts that glide to the newest message read, who is typing…
  • Model picker: Choose the AI model for a request by what it can do and what it costs: a trigger with the model's name opens a searchable list grouped by provider, with…
  • Task rows: Background work an agent is doing, one row per task: status as a glyph and a word, what it produced, how long it has run or took, a progress bar while…
  • Conversation: The scrolling column of a conversation: follows new content while you are at the bottom, stops when you scroll up to read, and offers a way back; shared…
  • Context cards: The knowledge an agent retrieved before it answered: one card per chunk with what it is about, the text it read with the search words marked, how…
  • Prompt suggestions: Ready-made prompts a person can start from or follow up with: chips, cards or a list; a picked one lifts off and flies into the composer as its text…
  • Plan: An agent's plan: numbered steps with live status, progress, and Approve / Edit / Reject when it needs sign-off; approving shows progress, and a refusal…
  • Approval card: The agent stops and asks before it acts: what it wants to do, exactly what that changes, any choices it needs, and Approve or Reject; both run your…
  • Tool call: One tool call in an agent's run: status, what it did and a short result on one quiet row that opens to the exact input and output; stops for permission…
  • Recommendation card: One suggestion from the agent that the person may take or leave: what it suggests, why, the expected effect and how sure it is (a meter and a word…
  • Citations: Inline numbered citations that preview their source on hover or focus, plus a numbered source list; streamed answers flow in at an even pace with the…
  • Reasoning: The agent's trace, fed by your stream: a shimmering label and the seconds so far while it works, then "Thought for N seconds"; steps that check off…
  • Attachment: A file tile: preview or typed glyph with the type named, name, size, upload progress, error with retry, and a keyboard-reachable remove.
  • Selection actions: Select a passage and hand it to the agent: a bar over the selection with quick actions, your own instruction and More; while the agent works it says so…
  • Message: One turn in a conversation with an agent: the person's words in a quiet bubble, the agent's answer on the page with its orb mark, trace, tool calls and…

Part of Beamline UI: polished, editable React components and complete screens for custom applications. Build your own style from any look; tokens, fonts, radii, motion; not only colours.