Clarx

Chat Input

An auto-resizing textarea with a send or stop button, designed for AI chat interfaces.

ChatInput is a controlled textarea that auto-resizes as the user types, submits on Enter, and switches to a stop button during streaming. It is a 'use client' component.

Streaming state

When isStreaming={true}, the textarea is disabled and the send button becomes a stop icon. Wire onStop to cancel the in-flight request.

Disabled

Use disabled to lock the input when a conversation has ended or the user lacks permissions.

Props

PropTypeDefaultDescription
placeholderstring"Message..."Textarea placeholder
onSubmit(value: string) => voidCalled with trimmed text on submit
onStop() => voidCalled when the stop button is clicked during streaming
isStreamingbooleanfalseShows stop button and disables textarea
disabledbooleanfalseFully disables the input
actionsReact.ReactNodeExtra elements rendered between textarea and send button
classNamestringAdditional class names on the outer wrapper

Keyboard shortcuts

KeyAction
EnterSubmit the message
Shift + EnterInsert a newline
EscapeClear the input

Source

packages/ui/src/chat-input.tsx — copy into components/ui/chat-input.tsx in your project.