Prompt Input
Allows a user to send a message with file attachments to a large language model. It includes a textarea, file upload capabilities, a submit button, and a dropdown for selecting the model.
The PromptInput component allows a user to send a message with file attachments to a large language model. It includes a textarea, file upload capabilities, a submit button, and a dropdown for selecting the model.
Install using CLI
Install Manually
Copy and paste the following code in the same folder.
Usage with AI SDK
Built a fully functional chat app using PromptInput, Conversation with a model picker:
Add the following component to your frontend:
Add the following route to your backend:
Features
- Auto-resizing textarea that adjusts height based on content
- File attachment support with drag-and-drop
- Image preview for image attachments
- Configurable file constraints (max files, max size, accepted types)
- Automatic submit button icons based on status
- Support for keyboard shortcuts (Enter to submit, Shift+Enter for new line)
- Customizable min/max height for the textarea
- Flexible toolbar with support for custom actions and tools
- Built-in model selection dropdown
- Built-in native speech recognition button (Web Speech API)
- Optional provider for lifted state management
- Form automatically resets on submit
- Responsive design with mobile-friendly controls
- Clean, modern styling with customizable themes
- Form-based submission handling
- Hidden file input sync for native form posts
- Global document drop support (opt-in)
Examples
Cursor Style
Props
<PromptInputProvider />
<PromptInput />
<PromptInputTextarea />
<PromptInputTools />
<PromptInputButton />
'ghost'auto<PromptInputSubmit />
'default''icon'<PromptInputBody />
Attachments
Attachment components have been moved to a separate module. See the Attachments component documentation for details on <Attachments />, <Attachment />, <AttachmentPreview />, <AttachmentInfo />, and <AttachmentRemove />.
<PromptInputHeader />
<PromptInputFooter />
<PromptInputActionMenu />
<PromptInputActionMenuTrigger />
<PromptInputActionMenuContent />
<PromptInputActionMenuItem />
<PromptInputActionAddAttachments />
<PromptInputSpeechButton />
<PromptInputSelect />
<PromptInputSelectTrigger />
<PromptInputSelectContent />
<PromptInputSelectItem />
<PromptInputSelectValue />
<PromptInputHoverCard />
00<PromptInputHoverCardTrigger />
<PromptInputHoverCardContent />
'start'