Skip to content
ProLifetime access for $199, paid once, every future release included
Truffle UI

Prompt Input

ProNew

An AI composer with a model picker, tool switches, starter prompts, files by drop or paste, and a send button that turns into stop.

Installation

pnpm dlx shadcn@latest add @viewport/prompt-input

First time? Add the @viewport registry to components.json. Setup takes one minute.

Usage

The code behind the preview above comes with Truffle Pro.

Props

PropTypeDefault
onSubmit*(prompt: string, files: File[], options: { model?: string; tools: string[] }) => void

Called with the trimmed prompt, any attached files, and the model and tools in effect.

—
onStop() => void

Called when the stop button is pressed while `loading`.

—
loadingboolean

Shows the stop button and disables sending.

false
placeholderstring"Ask anything…"
maxHeightnumber

Tallest the textarea may grow, in pixels.

200
attachmentsboolean

Allow attaching files with the button, by dropping them, or by pasting.

true
modelsPromptModel[]

Models offered in the picker. Leave out to hide it.

—
modelstring

Selected model id. Uncontrolled when omitted, starting at the first model.

—
onModelChange(id: string) => void—
toolsPromptTool[]

Switches such as web search or extended thinking, shown beside the attach button.

—
defaultToolsstring[]

Tool ids switched on at first render.

[]
suggestionsstring[]

Starter prompts shown while the field is empty. Choosing one fills the field.

—
toolbarReact.ReactNode

Extra controls rendered in the bottom-left.

—
classNamestring—

Accessibility

  • Enter sends, Shift+Enter adds a line, IME composition is respected.
  • The model picker is a menu of radio items with arrow keys and typeahead; tool switches report their pressed state.
  • Send and stop have distinct labels, and attached files are a labelled list with remove buttons.
  • Starter prompts hide without moving the composer and leave the tab order while hidden.