Prompt Input

AI prompt composer with actions, file attachments, and submit controls.

PromptInput is the chat composer: auto-growing textarea, attachment chips, action menu, tool buttons, model select, and a submit control that tracks ready, submitted, streaming, and error. Pair it with Conversation above the fold.

Installation

pnpm dlx cubix@latest add prompt-input --base radix

Usage

Import
import {
  PromptInput,
  PromptInputBody,
  PromptInputFooter,
  PromptInputSubmit,
  PromptInputTextarea,
  PromptInputTools,
} from "@/components/cubix/prompt-input"
Example
<PromptInput onSubmit={handleSubmit}>
  <PromptInputBody>
    <PromptInputTextarea />
  </PromptInputBody>
  <PromptInputFooter>
    <PromptInputTools />
    <PromptInputSubmit />
  </PromptInputFooter>
</PromptInput>

Note: Enter submits, Shift+Enter inserts a newline. Paste or drop files onto the form. Backspace on an empty field removes the last attachment.

Composition

 
PromptInput
├── PromptInputHeader
   └── PromptInputAttachments  PromptInputAttachment
├── PromptInputBody
   └── PromptInputTextarea
└── PromptInputFooter
    ├── PromptInputTools
       ├── PromptInputActionMenu
       ├── PromptInputButton
       └── PromptInputSelect
    └── PromptInputSubmit

Features

  • Input Group shell with header attachments and footer tools
  • Submit statuses: ready, submitted, streaming (stop), error
  • File attach, paste, drop, screenshot, and accept / size limits
  • Optional PromptInputProvider for lifted text and files

Empty

Disable submit until there is text or at least one attachment.

Typing

Use PromptInputProvider when text should live outside the form.

Attachments

Header chips render via Attachment. Remove from the chip or with Backspace when the field is empty.

Drop, paste, or attach files. Backspace on an empty field removes the last attachment.

Submit status

Drive the button from your chat transport. Streaming with onStop turns the control into a stop action.

Idle

Submitted

Streaming

Error

Tools

Footer tools hold the action menu, toggles, and a compact model select. A dedicated Model Selector component can replace the select later.

Disabled

Validation

Accepts images only, max 2 files, 200KB each.

Provider

With conversation

Typical chat layout: transcript above, composer below, status tied to the active turn.

You: Outline a safe cutover plan.

Assistant: Start with changelog, smoke tests, then migrations.

API Reference

PromptInput

PropTypeDefaultDescription
onSubmit(message: PromptInputMessage, event) => void | Promise<void>-Called with text and files when the form submits. Clears on success; keeps input on throw.
acceptstring-File accept filter for the hidden input, e.g. "image/*" or ".pdf,.txt".
multiplebooleanfalseAllow selecting more than one file at a time.
maxFilesnumber-Maximum attachment count. Extra files are rejected via onError.
maxFileSizenumber-Maximum file size in bytes. Oversized files call onError.
globalDropbooleanfalseWhen true, document-level drops add files (opt-in).
onError(error: PromptInputError) => void-Validation callback for accept, max_files, and max_file_size failures.
classNamestring-Additional classes for the form root.

PromptInputProvider

PropTypeDefaultDescription
initialInputstring""Initial text lifted outside the form.
childrenReact.ReactNode-Composer and any controls that need shared text or files.

PromptInputTextarea

PropTypeDefaultDescription
placeholderstring"What would you like to know?"Placeholder for the message field.
disabledboolean-Disable typing while the model is busy or the form is locked.

PromptInputSubmit

PropTypeDefaultDescription
status"ready" | "submitted" | "streaming" | "error""ready"Submit icon state. submitted shows a spinner; streaming shows stop when onStop is set.
onStop() => void-When status is submitted or streaming, click becomes stop instead of submit.
disabledboolean-Disable the control. Empty composers usually disable submit.