Prompt Input
Preview

Composable prompt form with text editor, actions, attachments, and submit states.

Overview

PromptInput is a visual form shell for composing chat prompts. It captures prompt text and optional file parts on submit, while the consumer owns sending, cancellation, upload, persistence, and chat state.

PromptInput owns one transient draft for its children. The text editor, attachments, submit button, speech button, and prompt-specific actions coordinate through internal composer state, so consumers do not need to install a prompt-level provider. PromptInputSubmit derives its enabled state from that draft and remains disabled while an attachment is loading, uploading, or failed. Omit status or pass null when idle; pass status="processing" to show a disabled spinner; pass status="streaming" to show an enabled stop button that calls onCancel.

Pass consumer-owned attachment display data to PromptInputAttachments when upload, asset, or send-payload ownership lives outside PromptInput. The list renders the standard attachment UI and contributes attachment lifecycle state to submit readiness without adding those files to onSubmit.files.

Usage

import { Card } from "@tilt-legal/cubitt-components/card";
import {
  Attachment,
  AttachmentInfo,
  AttachmentPreview,
  AttachmentRemove,
  Attachments,
  Conversation,
  ConversationContent,
  ConversationScrollButton,
  Message,
  MessageContent,
  MessageResponse,
  PromptInput,
  PromptInputActionAddAttachments,
  PromptInputActionMenu,
  PromptInputActionMenuContent,
  PromptInputActionMenuTrigger,
  PromptInputFooter,
  PromptInputReasoningSwitcher,
  PromptInputSpeechButton,
  PromptInputSubmit,
  PromptInputTextEditor,
  PromptInputTools,
  Shimmer,
  type PromptInputReasoningLevel,
  type UIMessage,
  usePromptInputAttachments,
} from "@tilt-legal/cubitt-components/chat-elements";

Examples

Default

Omit status or pass null when idle. Pass status="processing" to show a disabled spinner. Pass status="streaming" with onCancel to show an enabled stop button.

Reasoning Switcher

PromptInputReasoningSwitcher cycles through low, medium, high, and xhigh. Keep the selected value in app state and pass it into the chat runtime when sending a prompt.

Speech Input

PromptInputSpeechButton writes final and interim speech into PromptInputTextEditor. Use standalone Speech Input when dictation is needed outside a prompt composer.

Attachments

API Reference

PromptInput

Root prompt composer form. It owns transient text and attachment draft state for its children. Extends HTML form props except onSubmit and onError.

PropTypeDefaultDescription
onSubmit(message: PromptInputMessage, event: FormEvent<HTMLFormElement>) => void | Promise<void>-Called with prompt text and files. Required. Clears draft after successful submit.
initialInputstring""Initial text editor value.
acceptstring-Accepted file types for the hidden file input, for example image/*,.pdf.
multipleboolean-Allow selecting multiple files.
globalDropbooleanfalseAccept dropped files from the document instead of only the prompt form.
syncHiddenInputbooleanfalseLegacy native-form flag. File data is still delivered through onSubmit.
maxFilesnumber-Maximum number of files in the draft.
maxFileSizenumber-Maximum file size in bytes.
onError(err: { code: "max_files" | "max_file_size" | "accept"; message: string }) => void-Called when file validation rejects one or more files.
childrenReact.ReactNode-Prompt input children such as editor, footer, tools, and submit button.
classNamestring-Additional CSS classes for the form.

PromptInputMessage

Message object passed to PromptInput submit handlers.

FieldTypeDescription
textstringCurrent prompt text.
filesFileUIPart[]Attached files for the prompt.

usePromptInputAttachments

Hook for custom attachment UI inside PromptInput.

FieldTypeDescription
filesChatAttachmentFile[]Current draft attachment files.
add(files: File[] | FileList) => voidAdd files to the prompt draft.
remove(id: string) => voidRemove a draft file by id.
clear() => voidClear all draft files.
openFileDialog() => voidOpen the hidden file input.
fileInputRefReact.RefObject<HTMLInputElement | null>Ref to the hidden file input.

LocalReferencedSourcesContext

React context that stores prompt-local referenced source documents. PromptInput provides this context internally.

FieldTypeDescription
sources(SourceDocumentUIPart & { id: string })[]Current referenced source documents.
add(sources: SourceDocumentUIPart[] | SourceDocumentUIPart) => voidAdd one or more referenced sources.
remove(id: string) => voidRemove a referenced source by id.
clear() => voidClear referenced sources.

usePromptInputReferencedSources

Hook for custom referenced-source controls inside PromptInput.

Return TypeDescription
ReferencedSourcesContextThe prompt-local referenced source store from LocalReferencedSourcesContext.

PromptInputTextEditor

TipTap-powered text editor for the prompt draft. Extends HTML div props except onChange.

PropTypeDefaultDescription
placeholderstring"What would you like to know?"Placeholder shown when the editor is empty.
onChange(value: string) => void-Called when committed editor text changes.
classNamestring-Additional CSS classes for the editor root.

PromptInputBody

Layout passthrough for prompt body content. Extends all HTML div props.

PropTypeDefaultDescription
childrenReact.ReactNode-Body content.
classNamestring-Additional CSS classes for the wrapper.

PromptInputHeader

Header addon row for the prompt input. Extends InputGroupAddon props except align.

PropTypeDefaultDescription
childrenReact.ReactNode-Header content.
classNamestring-Additional CSS classes for the header.

PromptInputFooter

Footer addon row for tools and submit controls. Extends InputGroupAddon props except align.

PropTypeDefaultDescription
childrenReact.ReactNode-Footer content.
classNamestring-Additional CSS classes for the footer.

PromptInputTools

Inline wrapper for prompt tools. Extends all HTML div props.

PropTypeDefaultDescription
childrenReact.ReactNode-Tool buttons or menu triggers.
classNamestring-Additional CSS classes for the wrapper.

PromptInputAttachment

Convenience attachment item connected to the prompt draft store. Extends Attachment props except data and onRemove.

PropTypeDefaultDescription
dataChatAttachmentFile-Draft attachment file. Required.
classNamestring-Additional CSS classes for the attachment.

PromptInputAttachments

Attachment list connected to the prompt. By default it renders internal draft files. Pass data for consumer-owned attachments such as externally uploaded files. Extends Attachments props except children.

PropTypeDefaultDescription
datareadonly (ChatAttachmentFileData & { id: string })[]internal draft filesConsumer-owned attachment display data. Lifecycle state contributes to submit readiness but files are not included in onSubmit.files.
children(attachment: ChatAttachmentFileData & { id: string }) => ReactNodedefault attachment UIOptional custom renderer for each attachment.
onCancel(attachment: ChatAttachmentFileData & { id: string }) => void-Called by the default remove control while an attachment is uploading.
onRemove(attachment: ChatAttachmentFileData & { id: string }) => voidinternal draft removeCalled by the default remove control for removable attachments.
variant"grid" | "inline" | "list""inline"Attachment layout variant.
classNamestring-Additional CSS classes for the attachment list.

PromptInputActionAddAttachments

Menu item that opens the prompt input file picker. Extends MenuItem props.

PropTypeDefaultDescription
labelstring"Add photos or files"Menu item label.
onClickMenuItemProps["onClick"]-Called before the file picker opens; prevent default to skip opening.
classNamestring-Additional CSS classes for the menu item.

PromptInputActionAddScreenshot

Menu item that captures a screenshot and adds it as a prompt attachment. Extends MenuItem props.

PropTypeDefaultDescription
labelstring"Take screenshot"Menu item label.
onClickMenuItemProps["onClick"]-Called before screenshot capture; prevent default to skip capture.
classNamestring-Additional CSS classes for the menu item.

PromptInputActionMenu

Prompt tool menu root. Extends Menu props.

PropTypeDefaultDescription
childrenReact.ReactNode-Menu trigger/content.

PromptInputActionMenuTrigger

Button trigger for PromptInputActionMenu. Extends Button props.

PropTypeDefaultDescription
modeButtonProps["mode"]"icon"Button mode.
sizeButtonProps["size"]"md"Button size.
typeButtonProps["type"]"button"Button type.
variantButtonProps["variant"]"ghost"Button variant.
childrenReact.ReactNodeplus iconCustom trigger content.
classNamestring-Additional CSS classes for the button.

PromptInputActionMenuContent

Menu content for prompt actions. Extends MenuContent props.

PropTypeDefaultDescription
alignstring"start"Menu alignment inherited from MenuContent.
childrenReact.ReactNode-Menu items.
classNamestring-Additional CSS classes for the content.

PromptInputActionMenuItem

Generic prompt action menu item. Extends MenuItem props.

PropTypeDefaultDescription
childrenReact.ReactNode-Menu item content.
classNamestring-Additional CSS classes for the item.

PromptInputSubmit

Submit button connected to the prompt draft. Extends Button props except mode and size.

PropTypeDefaultDescription
status"processing" | "streaming" | nullnullRuntime status. processing disables the button and shows a spinner. streaming enables a stop button.
onCancelButtonProps["onClick"]-Called when the streaming stop button is activated.
sizeButtonProps["size"]"md"Button size.
disabledbooleanderived from draft and statusOverride disabled state. processing and unresolved attachments remain disabled.
variantButtonProps["variant"]derivedDefaults to default when ready to submit and secondary when disabled or streaming.
typeButtonProps["type"]"submit" or "button"Button type. Defaults to "button" while streaming.
childrenReact.ReactNodesubmit/status iconCustom button content. Defaults to submit arrow, spinner, or filled stop icon.
classNamestring-Additional CSS classes for the button.

PromptInputSpeechButton

Speech input button wired into the prompt text draft. Extends SpeechInput props.

PropTypeDefaultDescription
tooltipstring | { content: ReactNode; shortcut?: string; side?: TooltipContentProps["side"] }-Optional tooltip shown around the speech button.
onTranscriptionChange(text: string) => void-Called after final transcript text is committed to the editor.
onInterimTranscriptionChange(text: string) => void-Called after interim transcript text is mirrored into editor state.
onAudioRecorded(audioBlob: Blob) => Promise<string>-MediaRecorder fallback callback inherited from SpeechInput.

PromptInputReasoningSwitcher

Button that cycles through prompt reasoning levels.

PropTypeDefaultDescription
valuePromptInputReasoningLevel-Controlled reasoning level.
defaultValuePromptInputReasoningLevel"low"Initial uncontrolled reasoning level.
onValueChange(value: PromptInputReasoningLevel) => void-Called after the level cycles.
labelsPartial<Record<PromptInputReasoningLevel, string>>-Custom display labels for one or more levels.
aria-labelstringgeneratedAccessible label. Defaults to Reasoning: {label}.
sizeButtonProps["size"]"md"Button size.
typeButtonProps["type"]"button"Button type.
variantButtonProps["variant"]"ghost"Button variant.
classNamestring-Additional CSS classes for the button.

PromptInputReasoningLevel

ValueDescription
"low"Lowest reasoning level.
"medium"Medium reasoning level.
"high"High reasoning level.
"xhigh"Highest reasoning level.

PromptInputSelect

Select root for prompt controls. Extends Select props.

PropTypeDefaultDescription
childrenReact.ReactNode-Select trigger/content.

PromptInputSelectTrigger

Prompt-styled select trigger. Extends SelectTrigger props.

PropTypeDefaultDescription
childrenReact.ReactNode-Trigger content.
classNamestring-Additional CSS classes for the trigger.

PromptInputSelectContent

Select content for prompt controls. Extends SelectContent props.

PropTypeDefaultDescription
childrenReact.ReactNode-Select items.
classNamestring-Additional CSS classes for the content.

PromptInputSelectItem

Select item for prompt controls. Extends SelectItem props.

PropTypeDefaultDescription
childrenReact.ReactNode-Item content.
classNamestring-Additional CSS classes for the item.

PromptInputSelectValue

Select value renderer for prompt controls. Extends SelectValue props.

PropTypeDefaultDescription
classNamestring-Additional CSS classes for the value.

PromptInputHoverCard

Hover-card root for prompt controls. Extends PreviewCard props.

PropTypeDefaultDescription
openDelaynumber0Accepted for API parity with hover-card usage; currently rendered through PreviewCard.
closeDelaynumber0Accepted for API parity with hover-card usage; currently rendered through PreviewCard.

PromptInputHoverCardTrigger

Trigger for PromptInputHoverCard. Extends PreviewCardTrigger props.

PropTypeDefaultDescription
renderReact.ReactElement-Custom trigger element to render.
childrenReact.ReactNode-Trigger content.

PromptInputHoverCardContent

Content for PromptInputHoverCard. Extends PreviewCardContent props.

PropTypeDefaultDescription
alignstring"start"Alignment passed to PreviewCardContent.
classNamestring-Additional CSS classes for the content pane.

PromptInputTabsList

Unstyled tabs list layout helper. Extends all HTML div props.

PropTypeDefaultDescription
childrenReact.ReactNode-Tab groups.
classNamestring-Additional CSS classes for the list.

PromptInputTab

Tab section layout helper. Extends all HTML div props.

PropTypeDefaultDescription
childrenReact.ReactNode-Tab content.
classNamestring-Additional CSS classes for the tab.

PromptInputTabLabel

Tab label helper. Extends all HTML h3 props.

PropTypeDefaultDescription
childrenReact.ReactNode-Label content.
classNamestring-Additional CSS classes for the label.

PromptInputTabBody

Tab body helper. Extends all HTML div props.

PropTypeDefaultDescription
childrenReact.ReactNode-Body content.
classNamestring-Additional CSS classes for the body.

PromptInputTabItem

Tab item helper. Extends all HTML div props.

PropTypeDefaultDescription
childrenReact.ReactNode-Item content.
classNamestring-Additional CSS classes for the item.

PromptInputCommand

Prompt command root. Extends Command props.

PropTypeDefaultDescription
childrenReact.ReactNode-Command input/list/content.
classNamestring-Additional CSS classes for the command.

PromptInputCommandInput

Prompt command search input. Extends CommandInput props.

PropTypeDefaultDescription
classNamestring-Additional CSS classes for the input.

PromptInputCommandList

Prompt command list. Extends CommandList props.

PropTypeDefaultDescription
childrenReact.ReactNode-Command groups and items.
classNamestring-Additional CSS classes for the list.

PromptInputCommandEmpty

Empty command state. Extends CommandEmpty props.

PropTypeDefaultDescription
childrenReact.ReactNode-Empty state content.
classNamestring-Additional CSS classes for the empty state.

PromptInputCommandGroup

Command item group. Extends CommandGroup props.

PropTypeDefaultDescription
childrenReact.ReactNode-Group items.
classNamestring-Additional CSS classes for the group.

PromptInputCommandItem

Command item. Extends CommandItem props.

PropTypeDefaultDescription
childrenReact.ReactNode-Item content.
classNamestring-Additional CSS classes for the item.

PromptInputCommandSeparator

Command separator. Extends CommandSeparator props.

PropTypeDefaultDescription
classNamestring-Additional CSS classes for the separator.

On this page