Prompt input
A message box for an assistant or a chat: text that grows with its lines, attachments above it, a toolbar and a send button below. While a reply streams the send button becomes a stop button. For a plain multi-line field, use the textarea.
Install
npx shadcn@latest add @thrum-pro/prompt-inputThis is a Pro component. The command works once your project has a licence key: set up Pro or see pricing.
Automatically installs icons arrow-up, circle-alert, file, paperclip, stop and x from the icon set.
Data shape
type PromptAttachment = { id: string; name: string; size?: number };const files = [
{ id: "a", name: "Q4 revenue.csv", size: 48200 },
{ id: "b", name: "Northwind brief.pdf", size: 812000 },
];Props
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | – | The text, when the parent holds it. Use it with onValueChange. |
defaultValue | string | Default "" | The text at first, when the box holds it itself. |
onValueChange | (value: string) => void | – | Called with the text on every change. |
onSend | (value: string) => void | – | Called with the trimmed text on Enter or the send button. A box that holds its own text empties itself. |
onStop | () => void | – | Called when the stop button is pressed while a reply is on its way. |
status | "idle" | "submitted" | "streaming" | "error" | Default "idle" | submitted and streaming turn send into stop and hold back new sends. error marks the box and shows error under it. |
error | string | – | The message shown under the box while status is error. |
enterToSend | boolean | Default true | Enter sends and Shift with Enter breaks the line. With false, Enter breaks the line and Ctrl or Cmd with Enter sends. |
attachments | readonly PromptAttachment[] | Default [] | Files attached to the message, shown as chips above the text. A message with attachments and no text can be sent. |
onAttach | (files: File[]) => void | – | Called with the files picked through the attach button. Without it there is no attach button. |
onAttachmentRemove | (id: string) => void | – | Called with an attachment's id when its remove button is pressed. Without it the chips have no remove button. |
accept | string | – | The file types the attach button offers, as in the input's accept. |
toolbar | ReactNode | – | More controls for the toolbar, after the attach button: mode chips, a search toggle. |
maxLength | number | – | The most characters. A counter shows used and allowed, and screen readers read it with the box. |
sendLabel | string | Default "Send" | The name of the send button. |
placeholder | string | Default "Ask anything" | Shown while the box is empty. |
disabled | boolean | Default false | Dimmed; nothing can be typed, attached or sent. |
sound | boolean | Default true | Play a soft sound when an attachment is added or removed, if the visitor has sound on. |
className | string | – | Classes for the root element. It fills its container. |
…textarea props | ComponentProps<"textarea"> | – | aria-label, name, autoFocus and the rest go to the text box. |
Motion and sound
Motion
- The box grows a line at a time as the text wraps, up to 192 pixels, then scrolls. Browsers without field-sizing get the same from a small script.
- The frame's colour changes over 150 ms. Reduced motion: at once.
Sound
- A soft rising sound when files are attached and a falling sound when an attachment is removed.
- A soft click when a message is sent and a gentle closing tone when a reply is stopped.
Sound is off until the visitor turns it on. Pass sound={false} to keep this component silent. How sound works
Accessibility
- The text box needs a name: an aria-label as in the example, or a label element.
- The buttons are named Attach files, Send and Stop. Send is disabled while there is nothing to send.
- Attachments are a list named Attachments; each remove button is named with the file's name.
- The counter and the error are linked to the text box as its description. The error is announced when it appears.
- Enter does nothing while a word is being composed in an input method.
- A long file name is cut with an ellipsis and keeps its full text in a tooltip. Nothing overflows at 160 pixels wide.
| Keys | Action |
|---|---|
| Enter | Send. With enterToSend off, break the line. |
| Shift Enter | Break the line. |
| Ctrl Enter / Cmd Enter | Send, when enterToSend is off. |
| Tab | Move from the text to the attachments' remove buttons, the toolbar, and send or stop. |
Source
The source comes with Pro
TypeScript source · Copy-paste ready · MIT-compatible for client projects · Includes all dependencies
Files and dependencies
- Adds
components/ui/prompt-input.tsx- Packages
- None
- Brings along
- Sound engineButton
- Icons
arrow-upcircle-alertfilepaperclipstopx
Changelog
- 1.0.0 · 2026-12-03First release.