AI Elements

Prompt input

The box people type into. A form around an input group: a growing textarea, a footer for tools, and a submit that turns into stop while the answer streams.

packages/design-system/components/ai-elements/prompt-input.tsx

Examples

Enter to send, Shift Enter for a new line
Type and send: submitted, streaming, then ready
Enter to send, Shift Enter for a new line
With suggestions above

Anatomy

  1. 01Form
  2. 02Input group
  3. 03Textarea
  4. 04Footer
  5. 05Tools, left
  6. 06Submit, right

Usage

import {
  PromptInput, PromptInputFooter, PromptInputSubmit, PromptInputTextarea, PromptInputTools,
} from "@repo/design-system/components/ai-elements/prompt-input";

<PromptInput onSubmit={(message) => sendMessage({ text: message.text })}>
  <PromptInputTextarea value={input} onChange={(event) => setInput(event.target.value)} />
  <PromptInputFooter>
    <PromptInputTools>...</PromptInputTools>
    <PromptInputSubmit status={status} onStop={stop} disabled={!input.trim()} />
  </PromptInputFooter>
</PromptInput>

Props

PropTypeDefaultDescription
onSubmit*(message: { text, files }, event) => void | Promise<void>noneCalled on Enter or the submit button. The form clears after it resolves.
accept / multiple / maxFiles / maxFileSizestring / boolean / number / numbernoneAttachment rules. onError is called with max_files, max_file_size or accept.
globalDropbooleanfalseAccept files dropped anywhere on the page.
PromptInputTextarea placeholderstring"What would you like to know?"Enter submits, Shift Enter adds a line, and IME composition is respected.
PromptInputSubmit status"ready" | "submitted" | "streaming" | "error"noneThe icon: return, spinner, stop square, or X.
PromptInputSubmit onStop() => voidnoneWhile submitted or streaming, the button stops instead of submitting.
classNamestringnoneMerged last with cn(). Use it for layout (width, margin), not to restyle the component.

Guidance

Do

  • Pass the chat status so people can stop a long answer.

Don't

  • Disable the textarea while streaming; let people draft the next message.

Where it's used