Skip to content

Prompt input

An AI composer: auto-growing textarea, attachments, model and effort pickers, dictation, mentions and slash commands, a queue, and keyboard shortcuts. Adapted from HextaUI (MIT).

Compose it from its parts: PromptInput is the form and holds the state, PromptInputBody is the card, and the textarea, tools and actions sit inside it. Controls, the footer and the inset are in prompt-controls; mentions and commands are in prompt-menu. onSubmit receives the text, the uploaded files and the mentions.

Plain

With suggestions

Nothing sent yet

With attachments

Nothing sent yet

With mentions and commands

Nothing sent yet

With controls

Nothing sent yet

While a reply is pending

Nothing sent yet

With a character limit

Up to 80 characters19

Nothing sent yet

Disabled

Installation

npx shadcn@latest add @khaeli/prompt-input

Install @khaeli/foundation first: this item's styling lives in its tokens and [data-slot] rules.

Installs with

npm packages
  • @keyline-icons/react ^2.2.0

Keyboard

Enter
Sends the message. With submitOn="mod+enter" it starts a new line instead.
Shift+Enter
Starts a new line.
⌘+EnterCtrl+Enter
Sends the message, whatever submitOn is.
Escape
Stops the reply while one is pending and onStop is set. With a mention or command menu open, closes the menu first.
@/
Open the menu of a PromptInputMenu with that trigger: @ anywhere in the text, / only at its start. Keep typing to filter it.
Arrow UpArrow Down
Move through the open menu, from the last option round to the first. Focus stays in the textarea.
EnterTab
With a menu open, choose the highlighted option.
Tab
Moves through the composer: the attachments' remove buttons, the textarea, the tools, then Send and the footer's controls. Choosing from a control's menu returns focus to the textarea.
123
In the model picker, choose the model at that position. Arrow Up and Arrow Down move through the models.
Arrow LeftArrow RightHomeEnd
On the effort slider, lower or raise the effort, or go to its ends.
⌘+VCtrl+V
A paste longer than pasteLimit (5,000 characters) is attached as a file, Pasted text.txt. Its preview can put it back as text.

Accessible name

  • The textarea is named Message. Pass aria-label to PromptInputTextarea to say what is being written, such as Answer. It is described by a hidden hint that says which key sends.
  • Send, Stop, Queue message, Add files and more, the remove buttons of files and mentions, and the context ring name themselves. Pass label to PromptInputAddMenu and PromptInputSelect to change theirs.
  • A picker's button says its value: Model and effort: Balanced Medium, or Scope: This project.
  • A PromptInputTool is named from its text, as in Web search, on. Turn off.
  • A menu is a listbox named Mentions or Commands unless you pass label.
  • The composer announces what happens in a polite status: Message sent, a queued message, a file attached or refused, and why sending is blocked.
  • Send is never natively disabled. When there is nothing to send or sending is blocked it is aria-disabled, and its tooltip gives the reason. In a disabled composer Send also leaves the tab order, so nothing in the composer takes focus.

Registry JSON

The item as the shadcn CLI reads it, with every file it ships: https://ui.khaeli.com/r/prompt-input.json