An auto-growing chat composer with drag-and-drop file attachments, image/PDF preview tiles, and Enter-to-send.
Dependencies
Interaction Type
Type and press Enter to send (Shift+Enter for a newline). Drag files onto the composer or use the attach slot to add image/PDF previews.
Props
Options you can pass to customize this component.
valueControlled textarea value.
onValueChangeCalled with the new value on every textarea change.
onSendFired when the user submits via Enter or the send button.
placeholderPlaceholder shown when the value is empty.
disabledDisables the textarea, send button, and drag-and-drop.
minRowsMinimum visible rows before the textarea grows. Defaults to 1.
maxRowsMaximum visible rows before the textarea scrolls. Defaults to 8.
filesControlled list of attached files. Omit to disable attachments entirely.
onFilesChangeCalled when files are added (drag-drop or picker) or removed.
acceptAccepted MIME types, comma-separated. Defaults to PNG/JPEG/PDF.
maxFilesMaximum number of files. Extra files are dropped past the limit.
sendLabelAccessible label for the send button. Defaults to "Send".
Installation
How to use
import { useState } from "react"
import { InputMessage } from "@/components/ui/input-message"
export function Demo() {
const [value, setValue] = useState("")
return (
<InputMessage
value={value}
onValueChange={setValue}
onSend={() => setValue("")}
/>
)
}Source Code
Click the code icon in the top-right corner to view the source code.
License & Usage
// No code loaded.