Prompt Input
prompt-inputThe composer for an AI chat. Enter sends and Shift+Enter breaks a line without ever sending half an IME word. It grows with the text, takes pasted images as attachments, has a slot for model pickers and toggles, and its send button turns into stop while a reply streams.
"use client";
import { useState } from "react";
import { PromptInput } from "@/components/forme/prompt-input/prompt-input";
const chips = ["Web search", "Deep research"];
export function PromptInputDemo() {
const [streaming, setStreaming] = useState(false);
const [sent, setSent] = useState<string | null>(null);
const [on, setOn] = useState<string[]>(["Web search"]);
return (
<div className="flex w-full max-w-xl flex-col gap-3">
<PromptInput
streaming={streaming}
onStop={() => setStreaming(false)}
onSubmit={({ text, files }) => {
setSent(
files.length ? `${text} (+${files.length} file${files.length > 1 ? "s" : ""})` : text,
);
setStreaming(true);
setTimeout(() => setStreaming(false), 2400);
}}
toolbar={chips.map((chip) => {
const pressed = on.includes(chip);
return (
<button
key={chip}
type="button"
aria-pressed={pressed}
onClick={() =>
setOn((current) =>
pressed ? current.filter((entry) => entry !== chip) : [...current, chip],
)
}
className={`h-7 cursor-pointer rounded-full border px-2.5 text-caption-1-medium ${
pressed
? "border-transparent bg-ghost text-ghost-foreground"
: "border-control-border text-muted-foreground hover:bg-accent hover:text-foreground"
}`}
>
{chip}
</button>
);
})}
/>
<p aria-live="polite" className="px-2 text-caption-1-regular text-muted-foreground">
{sent
? streaming
? `Answering “${sent}”… press the square to stop.`
: `Sent “${sent}”.`
: "Enter to send, Shift+Enter for a new line. Paste an image to attach it."}
</p>
</div>
);
}Install
Adds the component, its registry dependencies, and the token stylesheet you import once.
API reference
Read from the source, so it is the API of the file you install. A prop marked * is required.
PromptInput
The composer at the bottom of every chat.
| Prop | Type | Default | Description |
|---|---|---|---|
onSubmit* | (prompt: { text: string; files: File[] }) => void | — | Called with the text and the attached files. Clear the field by returning. |
streaming | boolean | false | While true the send button becomes a stop button and calls onStop. |
onStop | () => void | — | |
placeholder | string | "Ask anything…" | |
label | string | "Message" | Accessible name for the field. |
attachments | boolean | true | Allows attachments through a paperclip button and by pasting images. |
toolbar | ReactNode | — | Controls in the footer, left of the send button: a model picker, toggles. |
disabled | boolean | — | |
className | string | — |
Related


Calendar
A month grid for a single date or a range, with no date library. Full WAI-ARIA keyboard support, min, max and disabled days, a range that previews under the pointer, and a fixed six-week height so nothing below it jumps.
inputs

File Dropzone
A drop target that is also a real file picker, so click, keyboard and drag all work. Checks type and size on drop as well as in the picker, and reports each rejected file by name.
inputs

Input
A text field with a real label, optional description, an error that is announced and wired up with aria-describedby, and room for an icon on either side. Sizes and the invalid state come from the same tokens as every other Forme surface.
inputs