Message Input
A textarea component with file attachment support, auto-resizing, and drag-and-drop capabilities.
The MessageInput component provides a rich textarea experience with support for file attachments, auto-resizing, and drag-and-drop file uploads.
Features
- Auto-resizing textarea
- File attachments support
- Drag and drop file uploads
- Submit on Enter (configurable)
- Stop generation button
- Fully customizable styling
Installation
Usage
Basic Usage
With File Attachments
With Stop Button
Props
The MessageInput component accepts two sets of props depending on whether file attachments are enabled.
Props
Prop | Type | Description | Default |
---|---|---|---|
value | string | Current input value | Required |
submitOnEnter | boolean | Whether to submit on Enter key | true |
stop | () => void | Function to stop generation | - |
isGenerating | boolean | Whether AI is generating | Required |
placeholder | string | Input placeholder text | "Ask AI..." |
allowAttachments | boolean | Enable file attachments |
With Attachments
When allowAttachments
is true
, these additional props are required:
Prop | Type | Description |
---|---|---|
files | File[] | null | Currently attached files |
setFiles | React.Dispatch<React.SetStateAction<File[] | null>> | Files state setter |
The component also accepts all standard textarea HTML attributes.
Features
Auto-resizing
The textarea automatically resizes based on content up to a maximum height of 240px.
File Attachments
Enable file attachments with drag-and-drop support:
Submit Behavior
Control whether Enter key submits the form:
Generation Control
Show stop button during generation:
Examples
In a Chat Form
Theming
The Chat component is using theme colors and fully themable with CSS variables.