A composable AI prompt composer with attachments, toolbar actions, send states, queued prompts, inline tokens, and drag-and-drop support.
Use PromptInput as the message composer for chat and agent interfaces.
import {PromptInput} from "@heroui-pro/react";
<PromptInput value={value} onSubmit={send} onValueChange={setValue}>
<PromptInput.Queue> {/* Optional */}
<PromptInput.Queue.List>
<PromptInput.Queue.Item>
<PromptInput.Queue.Item.Handle /> {/* Optional: reorder */}
<PromptInput.Queue.Item.Body>
<PromptInput.Queue.Item.Icon />
<PromptInput.Queue.Item.Content>{/* ... */}</PromptInput.Queue.Item.Content>
</PromptInput.Queue.Item.Body>
<PromptInput.Queue.Item.Actions>
<PromptInput.Queue.Item.Remove />
<PromptInput.Queue.Item.More />
</PromptInput.Queue.Item.Actions>
</PromptInput.Queue.Item>
</PromptInput.Queue.List>
</PromptInput.Queue>
<PromptInput.Shell>
<PromptInput.Content>
<PromptInput.Attachments>{/* ... */}</PromptInput.Attachments> {/* Optional */}
<PromptInput.TextArea placeholder="What do you want to know?" />
</PromptInput.Content>
<PromptInput.Toolbar>
<PromptInput.ToolbarStart>
<PromptInput.Action aria-label="Attach file">{/* ... */}</PromptInput.Action>
</PromptInput.ToolbarStart>
<PromptInput.ToolbarEnd>
<PromptInput.Send />
</PromptInput.ToolbarEnd>
</PromptInput.Toolbar>
</PromptInput.Shell>
<PromptInput.Footer>{/* ... */}</PromptInput.Footer> {/* Optional */}
</PromptInput>;Add workflow controls, such as review follow-ups and commit actions.
Use the secondary variant when the composer sits on a default surface.
The inline layout keeps the attachment, input, and send controls in one row while the textarea grows with the text.
The compact layout starts as a single-row pill and switches to the stacked composer once text wraps or attachments are added.
Pair PromptInput with ChatAttachmentInput.Dropzone to accept dropped files. While a file is dragged over the shell, the composer shows a dotted accent border.
Pair PromptInput with PromptSuggestion for starter prompts.
Use PromptInput.TokenInput instead of PromptInput.TextArea when the prompt should carry inline tokens such as @mentions or /commands. It is built on the React Aria Components TokenField, so its value is a TokenFieldValue segment list rather than a string, and it renders a contenteditable element instead of a textarea.
Drive it with usePromptInputTokens, which tracks the value and resolves the trigger the caret currently sits in. Wrap both the field and PromptInput.TokenSuggestions in PromptInput.Tokens so arrow keys and Enter move through the menu while the caret stays in the field. The query ends at the first space unless you pass allowsSpaces, and the menu closes when the caret moves out of the trigger or the field loses focus. Escape dismisses the menu for the current trigger until the caret leaves it; every other close, including close(), only hides the menu until the next edit or caret move.
The suggestion menu is anchored to the caret, not to the composer. For a composer docked to the bottom of the viewport, pass placement="top start" so the menu opens upward instead of covering the toolbar.
PromptInput.Tokens is a React Aria Autocomplete, so every menu and list box rendered inside it
joins the suggestion collection. Keep PromptInput.Toolbar and any other menus outside it.
TokenField is an alpha React Aria Components API. Its behavior and props may change in a future
release.
The token field owns the prompt and flattens it into a string for PromptInput.Send and the compact layout. Leave value on PromptInput unset, and clear the prompt with tokens.setValue(new TokenFieldValue([])).
A minimal composer with an @ mention menu:
import {Menu} from "@heroui/react";
import {PromptInput, TokenFieldValue, usePromptInputTokens} from "@heroui-pro/react";
const users = [
{id: "ada", name: "Ada Lovelace", username: "ada"},
{id: "grace", name: "Grace Hopper", username: "grace"},
];
function Composer() {
const tokens = usePromptInputTokens({triggers: ["@"]});
const items = users.filter((user) => user.username.startsWith(tokens.query));
return (
<PromptInput onSubmit={() => tokens.setValue(new TokenFieldValue([]))}>
<PromptInput.Shell>
<PromptInput.Tokens>
<PromptInput.Content>
<PromptInput.TokenInput tokens={tokens} />
</PromptInput.Content>
<PromptInput.TokenSuggestions tokens={tokens}>
<Menu items={items}>
{(item) => (
<Menu.Item id={item.id} onAction={() => tokens.insertToken(`@${item.username}`)}>
{item.name}
</Menu.Item>
)}
</Menu>
</PromptInput.TokenSuggestions>
</PromptInput.Tokens>
<PromptInput.Toolbar>
<PromptInput.ToolbarEnd>
<PromptInput.Send />
</PromptInput.ToolbarEnd>
</PromptInput.Toolbar>
</PromptInput.Shell>
</PromptInput>
);
}PromptInput.Queue shows queued follow-up prompts in a card above the composer. Place it next to PromptInput.Shell inside PromptInput. Keep queue rows text-only: store attachments in your queue model, and restore them to PromptInput.Attachments when the user edits a queued prompt.
When values and onReorder are set, users reorder rows by dragging PromptInput.Queue.Item.Handle, or by focusing it and pressing the arrow keys (Up/Down, or Left/Right when axis="x", flipped in right-to-left layouts).
The submitted, streaming, ready, and error states switch the send and stop behavior.
HeroUI follows the BEM methodology to ensure component variants and states are reusable and easy to customize.
The Prompt Input component uses these CSS classes:
.prompt-input: Root state wrapper.prompt-input--sm / .prompt-input--lg: Small and large sizes, from size.prompt-input__footer: Disclaimer/footer text.prompt-input__queue: Queued prompts container.prompt-input__queue-list: Scrollable queue list.prompt-input__queue-list-items: List of queued prompts inside the scroll area.prompt-input__queue-item: Single queued prompt row.prompt-input__queue-item-handle: Reorder handle (drag or arrow keys).prompt-input__queue-item-icon: Leading queue item icon.prompt-input__queue-icon: Default handle, leading, remove, and more icons.prompt-input__queue-item-body: Main queue row content stack.prompt-input__queue-item-content: Clamped prompt text (2 lines).prompt-input__queue-item-description: Secondary queue item text.prompt-input__queue-item-actions: Trailing row actions.prompt-input__queue-steer-arrow: Arrow before the default Steer label.prompt-input__queue-item-attachments: Attachment preview row inside a queue item.prompt-input__queue-item-attachments-overflow: Hidden attachment count label.prompt-input__shell: Composer surface.prompt-input__shell--primary / .prompt-input__shell--secondary: Shell variants, from variant.prompt-input__shell--compact / .prompt-input__shell--inline: Compact and inline layouts, from layout.prompt-input__content: Textarea and attachment content area.prompt-input__attachments: Attachment preview row.prompt-input__textarea: Text area.prompt-input__token-input: Contenteditable token field.prompt-input__token: Inline token pill.prompt-input__token-suggestions: Caret-anchored suggestion popover.prompt-input__toolbar: Absolute toolbar row.prompt-input__toolbar-start: Leading toolbar actions.prompt-input__toolbar-end: Trailing toolbar actions.prompt-input__send: Send/stop button.prompt-input__send-icon: Default send, stop, and error icons--prompt-input-max-height: Set on the root from maxHeight; caps .prompt-input__token-inputThe model picker in the default toolbar is a Model Selector.
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | internal | Controlled input value |
onValueChange | (value: string) => void | - | Called when the text changes |
onSubmit | () => void | - | Called when submit is requested |
onStop | () => void | - | Called by the send button in stoppable states |
status | 'ready' | 'submitted' | 'streaming' | 'error' | 'ready' | Composer run state |
isDisabled | boolean | false | Disable composer controls |
lockInputOnRun | boolean | true | Disable textarea while submitted/streaming |
maxHeight | number | string | 240 | Max input height, also as a CSS variable |
size | 'sm' | 'md' | 'lg' | 'md' | Composer size |
variant | 'primary' | 'secondary' | 'primary' | Surface styling variant |
layout | 'stacked' | 'compact' | 'inline' | 'stacked' | Composer layout and toolbar placement |
Extends HeroUI TextArea props.
| Prop | Type | Default | Description |
|---|---|---|---|
disableAutosize | boolean | false | Disable automatic height adjustment |
An alternative to PromptInput.TextArea that renders inline tokens. Extends React Aria Components TokenInput props. Enter submits and Shift+Enter inserts a newline, and Enter is ignored while the composer is running unless allowSubmitWhileRunning is set, matching PromptInput.TextArea.
| Prop | Type | Default | Description |
|---|---|---|---|
tokens | PromptInputTokenState | - | Required token state from usePromptInputTokens |
children | (segment: TokenSegment) => ReactElement | PromptInput.Token | Renders each token segment |
placeholder | string | 'What do you want to know?' | Text shown while the field is empty |
allowsNewlines | boolean | true | Whether Shift+Enter inserts a newline |
isReadOnly | boolean | false | Make the field read only |
isDisabled | boolean | inherited | Defaults to the composer's disabled and run-lock state |
Connects PromptInput.TokenInput to PromptInput.TokenSuggestions so arrow keys and Enter move through the menu while the caret stays in the field. Wrap only those two: it extends React Aria Autocomplete props, and any other menu inside it joins the suggestion collection. Renders no DOM of its own.
A suggestion menu anchored to the caret of the active trigger. Extends React Aria Components Popover props except triggerRef and getTargetRect, which it sets from the token state.
| Prop | Type | Default | Description |
|---|---|---|---|
tokens | PromptInputTokenState | - | Required token state from usePromptInputTokens |
isOpen | boolean | tokens.isOpen | Overrides open state |
placement | Placement | 'bottom start' | Placement relative to the caret |
The popover hides itself while its menu has no items, so narrowing isOpen is optional.
A non-editable inline token. Extends React Aria Components Token props. Exposes [data-selected] and [data-disabled] for styling.
Extends HeroUI Button props.
| Prop | Type | Default | Description |
|---|---|---|---|
tooltip | ReactNode | - | Optional tooltip content |
Extends HeroUI Button props. Uses the current prompt status to render send, loading, stop, or error icons.
Layout slots for composing the prompt input. Each slot supports the corresponding native element props.
| Prop | Type | Default | Description |
|---|---|---|---|
actionsVisibility | 'always' | 'hover' | 'hover' | When queue row actions are visible |
| Prop | Type | Default | Description |
|---|---|---|---|
values | T[] | - | Controlled queue values. Pass with onReorder to enable Motion reordering. |
onReorder | (values: T[]) => void | - | Called when items are reordered by dragging or with the handle's arrow keys. |
axis | 'x' | 'y' | 'y' | Reorder axis when drag and drop is enabled. |
| Prop | Type | Default | Description |
|---|---|---|---|
value | T | - | Item value from values. Required when reordering is enabled. |
Reorder handle for a queue row. Drag it, or focus it and press the arrow keys, to move its row. Includes a default aria-label ("Reorder queue item") and grip icon. Extends HeroUI Button props.
Presentational slots for queue row structure. Wrap Icon and Content in Body so the icon sits beside the clamped text and stays vertically centered. Content clamps text to two lines with an ellipsis.
Optional overflow label when you choose to render attachment previews inside a queue row.
| Prop | Type | Default | Description |
|---|---|---|---|
hiddenCount | number | - | Number of attachments hidden beyond the visible previews |
noun | string | 'files' | Noun used in the overflow label |
Action buttons for queue rows. Remove and More include default labels and icons. Extend HeroUI Button props.
Tracks a token field value and resolves the trigger the caret currently sits in.
| Option | Type | Default | Description |
|---|---|---|---|
triggers | string[] | ['@', '/'] | Strings that open the menu at a word boundary |
allowsSpaces | boolean | false | Whether the query may run past the first space |
defaultValue | TokenFieldValue | empty | Initial value when uncontrolled |
value | TokenFieldValue | - | Controlled value |
onChange | (value: TokenFieldValue) => void | - | Called whenever the value changes |
It returns value, setValue, inputRef, anchor, query, trigger, isOpen, insertToken(text, {appendSpace, value}), and close(). close() hides the menu until the next edit or caret move, while Escape keeps it closed for the current trigger. insertToken and close keep a stable identity, so menu items can capture them in onAction without a dependencies list.
Resources