UI

Input

A chat message composer with auto-growing input, file attachments, toolbar slots, and a send button that morphs into stop while streaming.

import { PromptInput } from '@uthereal/ui/prompt-input'

Prompt input playground

Loading interactive preview…

Overview

PromptInput is a standalone chat message composer. The attach button and optional toolbar actions sit at the inline start beside a rounded text field that grows smoothly from minRows to maxRows lines (6 by default) before scrolling. The send button rides the field's bottom-end edge, filling with the accent color when ready and morphing into a stop button while a reply streams. Attached files appear in a scrollable tray above the row with thumbnails, upload progress bars, retry controls, and remove badges.

The composer never sends messages or uploads files on its own: it reports text, accepted files, and named actions to your application, while you pass back status and attachments.

Usage

Basic composer

'use client'
import { useState } from 'react'
import { PromptInput } from '@uthereal/ui/prompt-input'

export function Composer({
  sendMessage,
  stopReply,
}: {
  sendMessage: (text: string) => Promise<void>
  stopReply: () => void
}) {
  const [status, setStatus] = useState<'idle' | 'submitting' | 'streaming'>(
    'idle',
  )

  return (
    <PromptInput
      status={status}
      onSubmit={async (text) => {
        setStatus('submitting')
        await sendMessage(text)
        setStatus('streaming')
      }}
      onStop={() => {
        stopReply()
        setStatus('idle')
      }}
    />
  )
}

Composing with Dictation

Use renderToolbarEnd to place Dictation at the inline-end edge of the composer row with zero coupling between components. When the user speaks, append or commit the transcript directly into controlled value state.

'use client'
import { useState } from 'react'
import { PromptInput } from '@uthereal/ui/prompt-input'
import { Dictation } from '@uthereal/ui/dictation'

export function VoiceComposer({ onSend }: { onSend: (text: string) => void }) {
  const [value, setValue] = useState('')

  return (
    <PromptInput
      value={value}
      onValueChange={setValue}
      onSubmit={(text) => {
        onSend(text)
        setValue('')
      }}
      renderToolbarEnd={({ disabled, status }) => (
        <Dictation
          size="md"
          disabled={disabled || status !== 'idle'}
          onCommit={(spoken) =>
            setValue((prev) => (prev ? `${prev.trimEnd()} ${spoken}` : spoken))
          }
        />
      )}
    />
  )
}

Examples

Attachments and streaming states

Uploading and failed file attachments alongside a streaming composer in dark mode with the soft variant.

  • invoices-march.pdf471 KB
  • ledger.xlsxUploading
  • scan.pngFile too large

Toolbar actions

Leading tool buttons (actions) paired with custom placeholder copy and soft fill styling.

Attachments & statuses

File picking, pasting, and drag-and-drop run through @zag-js/file-upload validation (accept, maxSize, maxFiles). Valid files reach onFilesAccept(files); invalid ones reach onFilesReject(rejections). Set maxFiles={0} to disable attachments and hide the attach button.

Attachment statusDisplay
pendingWaiting icon and statusLabels.pending text.
runningSpinner, statusLabels.running, and bottom progress bar (progress).
complete56px image preview thumbnail or 168×56 file card with binary size.
errorDanger border/icon, error reason, and optional Retry button (retryAction).

A message can be submitted when status is idle, the input is neither disabled nor readOnly, all attachments are complete, and either trimmed text or at least one attachment is present.

API reference

These serializable arguments and defaults come directly from the component schema.

ArgumentType / defaultDescription
labelstringDefault: "Message"Accessible name of the text field, e.g. "Message". Hidden by default: a chat composer is named by its context.
hideLabelbooleanDefault: trueHide the label visually (the default); it is still announced. Show it when the composer sits in a form.
descriptionstring—Supporting text below the field, announced with it. Use it for format hints and constraints.
errorstring—Validation message from your application. Setting it marks the field invalid; the message is linked to the field and announced politely.
requiredbooleanDefault: falseMarks the field as required for assistive technology and shows an indicator. Your application validates the value.
readOnlybooleanDefault: falseThe value can be focused, selected, and copied, but not edited. It is still submitted with a form.
disabledbooleanDefault: falseUnavailable and removed from the tab order. A disabled field is not submitted with a form.
namestring—Native form field name, submitted with the value in a form.
placeholderstringDefault: "Message"Text shown while the field is empty; "Message" by default, as in Arc. Never a substitute for the label.
defaultValuestringDefault: ""Initial text. Later argument edits do not reset an existing instance; use value and onValueChange to control it.
minRowsintegerDefault: 1Visible lines when empty, from 1 to 20.
maxRowsintegerDefault: 6Lines shown before the text scrolls: 6 by default, as in Arc, up to 20. Values below minRows act as minRows.
maxLengthinteger—Maximum number of characters the user can type. Omit it for no limit.
statusidle | submitting | streamingDefault: "idle"idle; submitting while your application sends the message (the send button shows a spinner); streaming while the reply arrives (the send button becomes a stop button).
submitLabelstringDefault: "Send"Accessible name and tooltip of the send button.
stopLabelstringDefault: "Stop"Accessible name and tooltip of the stop button.
sendingLabelstringDefault: "Sending"Announced while submitting.
submitOnEnterbooleanDefault: trueEnter sends and Shift+Enter starts a new line. Turn it off to send only with the button.
submitActionstring—Name of an action registered by your application, sent with the message. Read the text from the composer state.
stopActionstring—Name of an action registered by your application, sent when the stop button is pressed.
actionsPromptAction[]Default: []Up to six icon buttons after the attach button, at the start of the row, each with a stable ID, a label (its accessible name and tooltip), an icon and an action.
attachmentsPromptAttachment[]Default: []Attached files with their upload status (pending, running with progress, complete or error), described by your application. A preview URL shows an image as a 56px thumbnail; other files show as a card.
maxFilesintegerDefault: 10Most attachments (10 by default). The attach button shows by default, as in Arc; your application uploads the files it reports. 0 hides the attach button and turns off pasting and dropping files.
acceptstring[]—Accepted file types as MIME types ("image/*") or extensions (".pdf"). Omit it to accept any file.
maxSizeinteger—Largest accepted file in bytes. Omit it for no limit.
attachLabelstringDefault: "Attach files"Accessible name of the attach button.
dropLabelstringDefault: "Drop files to attach"Shown in the box in place of the placeholder while files are dragged onto the composer.
attachmentsLabelstringDefault: "Attachments"Accessible name of the list of attached files.
statusLabelsFileStatusLabels—Status text of an attachment per upload state.
removeActionstring—Name of an action registered by your application, sent with the attachment ID to remove it.
retryActionstring—Name of an action registered by your application, sent with the attachment ID to retry a failed upload.
removeLabelstringDefault: "Remove {name}"Accessible name of each remove button; {name} is the file name.
retryLabelstringDefault: "Retry {name}"Accessible name of each retry button; {name} is the file name.
variantoutline | softDefault: "outline"Composer surface: outline (a bordered field) or soft (a tinted fill).
sizesm | md | lgDefault: "md"Icon size of the buttons and attachments. The box keeps Arc’s 16px text and 32px send button at every size.
recipestudio | softDefault: "studio"Visual treatment. Both recipes use the same interaction behavior.
themePromptInputTheme—Color mode, accent, and tokens of the field. The buttons follow the mode and accent. See Theming.
motionnone | subtle | expressiveDefault: "subtle"The box growing with its text, attachments popping in, the send arrow swapping on each send, and button presses. System reduced-motion preferences take precedence (Arc’s fades: attachments fade, the send arrow crossfades, the tray and box jump).
dirltr | rtl—Reading direction. Omit it to inherit the page direction.

React integration

PropPurpose
value, onValueChange(value)Control the composer text; onValueChange('') fires after sending.
onSubmit(value)Receives trimmed text on send before the field clears.
onStop()Called when the stop button is pressed while status="streaming".
onAction(action, itemId?)Receives submitAction, stopAction, toolbar action IDs, and attachment IDs.
onFilesAccept / onFilesRejectPicked, pasted, or dropped files that passed or failed accept/maxSize/maxFiles.
renderToolbar(state)Extra controls after actions, before the text box (e.g., a model picker).
renderToolbarEnd(state)Trailing controls at the inline-end of the row (e.g., Dictation).
renderIcon(name, context)Replace named icons (file, status, remove, retry, attach, send, stop).
refForwards directly to the underlying <textarea> element.
preset, tokens, className, styleApplication defaults, --ui-* token overrides, and root styling.

Keyboard & accessibility

KeyAction
EnterSends the message when submitOnEnter is true (ignores IME compose).
Shift+EnterInserts a newline without sending.
TabMoves across attachment controls, toolbar buttons, textarea, and send/stop.
  • The <textarea> is named by label (visually hidden by default via hideLabel) and wired to description and error via aria-describedby.
  • The send button stays focusable while empty (aria-disabled="true"), morphs in place into Stop while streaming without losing focus, and announces sendingLabel via a pre-mounted polite role="status" live region outside the button while submitting.
  • Removing an attachment moves focus to the next attachment's remove button or returns focus to the <textarea>.
  • All spacing and alignment use logical CSS properties for dir="rtl" support, and forced-colors: active maps borders, error outlines, send/remove fills, and focus rings to system colors.

Motion & theming

The text box height follows content on the smooth spring (0.4s, bounce 0). Attachment chips pop in (scale: 0.9, 2px blur) on a spring (0.3s, bounce 0.22) and reflow cleanly when siblings exit. The send button morphs fill color over 240ms and swaps between the send arrow, spinner, and stop square on the morph spring (0.42s, bounce 0.16).

Under prefers-reduced-motion: reduce, box and tray heights cut immediately while chips and send icons keep short opacity crossfades and press scale is removed. Setting motion="none" makes every transition immediate (0ms).

TokenRole
--ui-surface, --ui-surface-raised, --ui-highlightFile card fill, outline box surface, and soft box fill.
--ui-border, --ui-border-strong, --ui-border-widthResting border, focused border, and border stroke width.
--ui-text, --ui-text-secondary, --ui-mutedInput text, file icons, placeholders, and metadata.
--ui-accent, --ui-accent-foreground, --ui-accent-subtleReady send button fill, icon contrast, and drag-over tint.
--ui-danger, --ui-track, --ui-focus-ringFailed attachment state, upload progress rail, focus ring.

An application-wide UtherealProvider supplies theme, recipe, and motion defaults.

Composition

In an agent composition, PromptInput is a leaf component whose text lives at /fields/instance-<id>/value. submitAction fires before the text clears so the host reads the submitted message from state; toolbar, remove, and retry actions pass their itemId. See Building with agents.

{
  "type": "PromptInput",
  "props": {
    "placeholder": "Ask anything",
    "submitAction": "send_message",
    "stopAction": "stop_reply"
  },
  "children": []
}

On this page