PromptInput

Composer that grows with the text. Send wakes when there is something to send and morphs into stop while a reply runs. AI.

Open playground

About

PromptInput is a React component in the AI category of smoui. It is typed, ships no stylesheet, follows your theme through CSS variables, and honors prefers-reduced-motion. Import it with import { PromptInput } from "@ashutoshswamy/smoui" and set onSend, onStop, loading among its 4 props.

Install

Terminal
npm i @ashutoshswamy/smoui

Usage

TSX
import { PromptInput } from "@ashutoshswamy/smoui";

<PromptInput
  onSend={async (text) => { await ask(text); }}
  onStop={() => abort()}
/>

Props 4

onSend

Called on Enter or the send button. A returned promise holds the loading state.

(text: string) => Promise<unknown> | void
onStop

Called when stop is pressed.

() => void
loading

Controlled loading state.

boolean
simulateMs

For demos: with no onSend, stay loading this long.

numberdefault 0