Skip to content
Thrum

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-input

This 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
type PromptAttachment = { id: string; name: string; size?: number };
Sample
const files = [
  { id: "a", name: "Q4 revenue.csv", size: 48200 },
  { id: "b", name: "Northwind brief.pdf", size: 812000 },
];

Props

PropTypeDefaultDescription
valuestring–The text, when the parent holds it. Use it with onValueChange.
defaultValuestringDefault ""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.
errorstring–The message shown under the box while status is error.
enterToSendbooleanDefault trueEnter sends and Shift with Enter breaks the line. With false, Enter breaks the line and Ctrl or Cmd with Enter sends.
attachmentsreadonly 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.
acceptstring–The file types the attach button offers, as in the input's accept.
toolbarReactNode–More controls for the toolbar, after the attach button: mode chips, a search toggle.
maxLengthnumber–The most characters. A counter shows used and allowed, and screen readers read it with the box.
sendLabelstringDefault "Send"The name of the send button.
placeholderstringDefault "Ask anything"Shown while the box is empty.
disabledbooleanDefault falseDimmed; nothing can be typed, attached or sent.
soundbooleanDefault truePlay a soft sound when an attachment is added or removed, if the visitor has sound on.
classNamestring–Classes for the root element. It fills its container.
…textarea propsComponentProps<"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.
KeysAction
EnterSend. With enterToSend off, break the line.
Shift EnterBreak the line.
Ctrl Enter / Cmd EnterSend, when enterToSend is off.
TabMove from the text to the attachments' remove buttons, the toolbar, and send or stop.

Source

SourcePro

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. 1.0.0 · 2026-12-03First release.

Loading index…

Keyboard shortcuts

/Ctrl KSearch components, docs and actions
?Show this list
AAppearance studio
SSound on or off
MFull or reduced motion
TTheme: auto, light, dark
GSurface: solid or frosted
BBackdrop photograph (under glass)
CCorner radius: square to round
RReplay the demo, on a component page
DDraw new data, on a component page
←→HomeEndMove the cursor in a focused chart
EscClose a dialog, or leave a chart cursor