Skip to content

Prompt input

Accepts a prompt to send, with files and actions.

Press Enter or Send to try it. Shift+Enter adds a line.

prompt-input-demo.tsx

Installation

The CLI adds the files, packages, theme variables, and Tailwind plugin that this component uses. Before you run it, set up your project.

Composition

  • PromptInput

    Owns the draft value, the submit key, and the file drop. Accepts TextField props for the value and validation.

    • PromptInputTextArea

      Grows from minRows to maxRows, then scrolls.

    • PromptInputFooter

      Put your own controls beside the submit button.

      • PromptInputSubmit

Keyboard

Set submitKey="mod+enter" for multi-line input. IME composition never submits.

Enter sends. Shift+Enter adds a line. This is the default.

Mod+Enter sends. Enter adds a line. Use this for a multi-line editor.

prompt-input-keyboard-demo.tsx

Attachments

Set onFilesDropped to accept dropped files. Also install Attachment and File trigger.

  • Release-checklist.pdf

    278 KBUploaded

Drop files anywhere on the composer, or use the attach button. Sending clears the list.

prompt-input-attachments-demo.tsx

Stop while streaming

Set isPending and onStop to change Send to Stop.

While the answer streams, Send becomes Stop.

prompt-input-stop-demo.tsx

Drag and drop

While a file is over the frame, an overlay shows dropLabel.

  • The frame shows a dashed drop area while a file is over it.
prompt-input-drop-demo.tsx

Full transcript

The second prompt fails once to show the error state. Also install Message, Reasoning, Response, Copy button and Source link.

You

How does the composer handle a long prompt?
Thought

Response complete
The textarea grows one row at a time until it reaches maxRows, which is 8 by default. After that it scrolls, so the footer and the Send button stay in view. Set minRows to start with a taller box.

Copy the answer, or send the next prompt.

prompt-input-transcript-demo.tsx

API reference

vip/ui adds or changes the props below. For all other props, see React Aria TextField (opens in a new tab).

PromptInput

label: string
An accessible name for the textarea. The label is visually hidden. Without it, the textarea is named Message.
placeholder: string
Placeholder text in the default textarea. Pass it to PromptInputTextArea when you compose the children.
submitKey: "enter" | "mod+enter" = "enter"
Controls which key sends. Enter sends with Shift+Enter for a line, or Mod+Enter sends with Enter for a line. IME composition never submits.
isPending: boolean = false
Changes Send to Stop when onStop is set. Without onStop, Send is disabled.
onSubmit: (value: string) => void
Called with the textarea value on send. Focus returns to the textarea. If value is not set, the textarea clears after each send.
onStop: () => void
Called when the user stops a pending run.
onFilesDropped: (files: File[]) => void
Called with files dropped on the frame. Without it, the frame ignores drops and no overlay shows.
dropLabel: string = "Drop files to attach"
Copy shown in the overlay while files are dragged over the frame.
size: "xs" | "sm" | "md" | "lg" | "xl"
Sets the height, text size, and padding of the frame.

PromptInputTextArea

minRows: number = 1
Rows shown at rest.
maxRows: number = 8
Rows shown before the textarea starts to scroll.

PromptInputSubmit

Renders Send, or Stop while isPending and onStop are set. Accepts Button props for variant, size, and aria-label.

isDisabled: boolean
Disables the button. Send is also disabled while the textarea is empty.