PromptInput
proPromptInput combines autosizing message entry, attachments, command selection, and explicit leading and trailing toolbars.
Installation
Add this component with the NateUI CLI.
Examples
Compact
Attachments
Mentions & Commands
Busy And Stop
Extension Above Card
API
PromptInput
| Prop | Description | Type | Default |
|---|---|---|---|
contentMode | Selects the text model or structured-parts model. The two modes have mutually exclusive state props. | 'text' | 'parts' | 'text' |
onSubmit | Required. Receives trimmed readable text and current attachments. In parts mode, the optional third argument contains the original parts plus reference ranges measured against the trimmed emitted text. | (value: string, attachments: AttachmentData[], details?: PromptInputSubmissionDetails) => void | — |
layout | Uses a stacked composer or a single-row compact start state. | 'stacked' | 'compact' | 'stacked' |
attachments | Controlled attachment records rendered above the field. | AttachmentData[] | — |
onAttachmentsChange | Receives selected and removed attachment records. | (attachments: AttachmentData[]) => void | — |
attachmentAccept | Native file-input accept filter. | string | — |
commands | Command records filtered when the caret is in a / token. Records without an outcome preserve legacy insertion (value ?? id) and callback behavior; kind: 'command' creates a structured command part. | PromptInputCommand[] | [] |
suggestions | Shared-menu records filtered by their @ or / trigger. | PromptInputSuggestion[] | [] |
emptyState | Content announced when a configured trigger group has no filtered matches. | ReactNode | 'No matching options' |
onCommandSelect | Called after a command is selected. Legacy commands insert their slash token first; commands with an outcome apply that outcome. | (command: PromptInputCommand) => void | — |
onSuggestionSelect | Called after a suggestion is selected, including callback-only action outcomes. Selection does not submit the message. | (suggestion: PromptInputSuggestion) => void | — |
renderReferenceIndicator | Renders a decorative indicator over the reserved leading @ glyph in parts mode. Returning null or undefined keeps the visible @ fallback. | (reference: PromptInputReference) => ReactNode | — |
onStop | Called by PromptInput.Submit while status="busy". | () => void | — |
status | Switches the submit control between send and stop. | PromptInputStatus | 'idle' |
value | Controlled string-mode message value. Pair with onChange; unavailable in parts mode. | string | — |
onChange | Receives each string-mode value change; unavailable in parts mode. | (value: string) => void | — |
parts | Controlled structured content. Pair with onPartsChange; unavailable in text mode. | PromptInputPart[] | — |
defaultParts | Initial uncontrolled structured content; available only with contentMode="parts". | PromptInputPart[] | [{ type: 'text', text: '' }] |
onPartsChange | Receives each structured-parts change; unavailable in text mode. | (parts: PromptInputPart[]) => void | — |
placeholder | Text shown when the message field is empty. | string | 'Message…' |
ref | Exposes clear() and focus() methods. | Ref<PromptInputRef> | — |
...formProps | Standard <form> attributes forwarded to the root. | ComponentProps<'form'> | — |
String mode is the default and accepts value/onChange. Structured mode requires contentMode="parts" and accepts parts/onPartsChange or defaultParts; it rejects value/onChange so the same text is not stored twice. details.parts retains text, reference and command parts, including surrounding whitespace. Command parts carry their stable id and display label; the readable projection uses /${id}. details.references contains reference occurrences within the trimmed submitted string, with UTF-16 start and end offsets.
renderReferenceIndicator affects only the aria-hidden visual overlay; reference parts, textarea text, caret positions, and submitted offsets continue to use the literal @label projection. The callback result is presentation and is never stored in the serializable parts. The native @ glyph keeps its original inline width beneath the indicator. Highlighted command tokens retain the readable literal /id; command icons remain in the menu.
PromptInput.Toolbar
Use one ToolbarStart and one ToolbarEnd inside each Toolbar. The end group contains PromptInput.Submit explicitly.
| Part | Description |
|---|---|
Extension | Bounded bar above the card (queue row, context strip). Defaults carry the boundary; className overrides via tailwind-merge. |
ToolbarStart | Leading actions, such as AttachButton or a caller-owned picker. |
ToolbarEnd | Trailing controls and Submit. |
AttachButton | Opens the native multi-file picker owned by the root composer. |
Submit | Sends the current text/attachments, or stops while busy. |
Types
PromptInputProps intersects the shared form/composer props with exactly one of PromptInputTextProps or PromptInputPartsProps.