Docs
Chat Input

Chat Input

A chat input component that autoresizes to fit the content and features a submit button.

A versatile chat input component that comes pre-styled with a modern look. It features automatic height adjustment based on content, a submit button, and smart keyboard handling. Press Enter to submit your message or Shift+Enter to add a new line. The component is composed of a textarea and a submit button, which can be customized or used individually.

Installation

pnpm dlx shadcn@latest add https://simple-ai.dev/r/chat-input.json

Usage

import { ChatInput, ChatInputTextArea, ChatInputSubmit } from "@/components/ui/chat-input"
<ChatInput variant="default">
  <ChatInputTextArea placeholder="Type a message..." />
  <ChatInputSubmit />
</ChatInput>

Props

ChatInput

PropTypeDefaultDescription
variant"default" | "unstyled""default"The visual style variant of the chat input
valuestring-The controlled value of the textarea
onChangefunction-Callback when the textarea value changes
onSubmitfunction-Callback when the message is submitted
loadingbooleanfalseWhether the input is in a loading state
onStopfunction-Callback to stop an ongoing action (shown when loading)
rowsnumber1Initial number of rows to display in the textarea

Examples

Default

Unstyled

Unstyled with initial rows