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, month and year pickers, min, max and disabled days, a range that previews under the pointer or the keyboard, and a fixed six-week height so nothing below it jumps.
inputsColor picker
A full colour editor: a saturation and brightness area, hue and opacity rails, a hex field, numeric channels, screen sampling and preset swatches — all composed from parts, opened from a trigger chip that previews the value.
inputsColor selector
A row of colour swatches where exactly one is chosen. Real radio inputs inside a fieldset, so forms, required state, arrow keys and screen-reader grouping all work natively, and one selection ring hops between swatches.
inputs