Ballmac UI home

Prompt Input

An auto-growing chat input: Enter sends, Shift+Enter adds a line (IME-safe), the send button turns into Stop while streaming, with file attachment chips and a toolbar slot.

Installation

$ pnpm dlx shadcn@latest add @ballmac/prompt-input

Usage

import { PromptInput, PromptInputTextarea, PromptInputToolbar, PromptInputSubmit, PromptInputAttachButton, PromptInputAttachments, usePromptInput } from "@/components/ballmac/prompt-input"

The full example is in the Code tab above.

Examples

With attachments

API reference

<PromptInput>

PropTypeDefault
onSubmit

Called with the trimmed text and attached files on Enter or the send button. Uncontrolled inputs clear themselves afterwards.

(value: string, files: File[]) => void—
value

Controlled text. Clear it yourself in onSubmit.

string—
defaultValue

Initial text when uncontrolled.

string""
onValueChange

Called on every edit.

(value: string) => void—
files

Controlled attachments.

File[]—
onFilesChange

Called when files are attached or removed. Nothing is uploaded; that is your job.

(files: File[]) => void—
status

"streaming" turns the send button into a Stop button and blocks new submissions.

PromptInputStatus"idle"
onStop

Called by the Stop button while streaming.

() => void—
disabled

Disables typing, attaching and sending.

booleanfalse

<PromptInputTextarea>

PropTypeDefault
maxHeight

Height (px) the textarea grows to before it scrolls.

number200

<PromptInputSubmit>

PropTypeDefault
submitLabel

Accessible name of the send button.

string—
stopLabel

Accessible name of the stop button.

string—

<PromptInputAttachButton>

PropTypeDefault
accept

File types to accept, as for <input type="file" accept>.

string—
multiple

Allow picking several files at once.

booleantrue
label

Accessible name of the icon button.

string—

Also accepts the standard attributes of its root element.

Accessibility

KeyAction
EnterSends the message (ignored while an IME composition is active)
Shift + EnterInserts a new line
TabMoves to the attach button, toolbar controls and send/stop

Use with AI

The message composer for chat UIs. <PromptInput onSubmit={(text, files) => …} status onStop> renders a textarea, attachment chips and a send button by default; compose PromptInputTextarea, PromptInputAttachments, PromptInputToolbar, PromptInputAttachButton and PromptInputSubmit for custom layouts. With the shadcn MCP server set up (guide), ask your agent:

Add the Ballmac UI Prompt Input (@ballmac/prompt-input) to this project with the shadcn MCP, then use it where it fits.

Use it for

  • The input at the bottom of an AI chat
  • A 'describe what you want' box that sends to a model and can be stopped mid-response
  • Composer that needs a model picker or other controls next to the send button

Not for

  • Plain multi-line form fields (use textarea)
  • Search boxes with results as you type (use an input or command menu)

Registry JSON: https://ui.ballmac.com/r/prompt-input.json

Credits

Free to use in personal and commercial projects.