AI composer textarea with auto-grow, send/stop button morph, attachment slots, and Enter-to-send.
Dependencies
Interaction Type
Type and press Enter to send (Shift+Enter for newline, IME-guarded). Send glyph launches upward on submit while the field relaxes to one row. During streaming the send button crossfades to a stop button.
Props
Options you can pass to customize this component.
valueControlled textarea value.
defaultValueInitial value for uncontrolled usage.
onValueChangeCalled with the new value on every textarea change.
onSubmitFired when the user submits via Enter or the send button.
streamingWhen true, the send button morphs into a stop button.
onStopFired when the user clicks the stop button during streaming.
placeholderPlaceholder shown when the textarea is empty.
maxRowsMaximum visible rows before internal scroll. Defaults to 6.
disabledDisables the textarea and all buttons.
nameForm field name attribute forwarded to the textarea.
startSlotSlot rendered before the textarea (e.g. attach button).
endSlotSlot rendered after the textarea and before the send button (e.g. model picker).
classNameAdditional CSS classes for the container.
Installation
How to use
import { useState } from "react"
import { AiInput } from "@/components/ui/ai-input"
export function Demo() {
const [value, setValue] = useState("")
return (
<AiInput
value={value}
onValueChange={setValue}
onSubmit={() => setValue("")}
placeholder="Ask anything..."
/>
)
}Source Code
Click the code icon in the top-right corner to view the source code.
License & Usage
// No code loaded.Fast
Quick, everyday answers