Prompt Input

Pro

The message composer of an AI chat: a growing text box with send / stop, attachments under a policy, `/` commands, a model picker, a mic toggle and a slot for your own tools.

</>sv-prompt-input aichatcomposerinputattachmentsslash-commands
import { SvPromptInputComponent } from '@styloviz-pro/ai-chat';

Demo & usage

Basic usage

Pro

Usage example — open the gallery for the full interactive demo.

Pro

An interactive demo for this component lives in the gallery.

Open live demo

More examples

Everything on

Pro

Compact pill

Pro

When to use

  • The input of a chat you are assembling yourself — `sv-ai-chat` already uses it.
  • A one-line "ask AI" box on a dashboard card (`layout="pill"`).

Async states

None — this component has nothing to load, so it has no loading, empty or error state to drive.

Inputs

NameTypeDefaultDescription
valuestring (two-way)''The draft. Two-way.
placeholderstring | nullnullPlaceholder text; `null` uses the `placeholderPanel` label.
layoutSvPromptInputLayout'block'`block` (multi-line box, toolbar underneath) or `pill` (one compact row).
busybooleanfalseA reply is in flight: the send button becomes stop, and Enter does nothing.
disabledbooleanfalseDisable the whole composer.
modelsreadonly ChatAiModel[][]Models offered by the picker. Empty hides the picker.
selectedModelChatAiModel | null (two-way)nullThe chosen model. Two-way.
attachablebooleanfalseShow the attach button. The host owns the upload; the component owns the policy.
attachmentsreadonly ChatAttachment[] (two-way)[]Files on the draft, refused ones included — each refusal stays visible with its reason, because a file that silently fails to attach is one the user believes they sent. Two-way.
attachmentLimitsSvChatAttachmentLimits | nullnullCount, size and type limits for attachments (`svCheckAttachments`). `null` uses the defaults.
slashCommandsreadonly SvSlashCommand[][]Commands offered when the message starts with `/`. Empty turns the menu off.
voicebooleanfalseShow the mic toggle. Wire `micToggle` to your recorder.
listeningbooleanfalseThe recorder is listening — the mic shows pressed.
labelsPartial<SvAiChatProLabels>{}Per-instance text, merged over the registry's `aiChatPro` labels.

Outputs

EventPayload typeDescription
submittedSvPromptSubmitThe user sent the draft. The box clears itself afterwards.
stopvoidThe user pressed stop while `busy`. Abort your request here.
filesPickedreadonly File[]Files the user picked that passed the policy — upload these.
slashCommandSvSlashCommandA command was chosen from the `/` menu.
micTogglebooleanThe mic was pressed. The payload is the state asked for: `true` to start listening.
valueChangestringEmits the new `value` whenever it changes — the output half of `[(value)]`.
selectedModelChangeChatAiModel | nullEmits the new `selectedModel` whenever it changes — the output half of `[(selectedModel)]`.
attachmentsChangereadonly ChatAttachment[]Emits the new `attachments` whenever it changes — the output half of `[(attachments)]`.

Customization & theming

  • `layout`: `block` (multi-line box, toolbar underneath) or `pill` (one compact row).
  • `(submitted)` carries `{ text, attachments, command }` and the box clears itself.
  • The `/` menu and the model menu are portalled to `<body>` and clamped to the viewport, so a composer at the foot of an `overflow: hidden` panel never clips them.
  • Project your own tools with `<button svPromptTools>` — they sit in the toolbar beside the built-ins.
  • Text comes from the `aiChatPro` labels (`provideSvLabels({ aiChatPro: { … } })`), or per instance through `[labels]`.

Best practices

  • Do: Bind `busy` while a reply streams: send becomes stop, and Enter stops sending without disabling the box, so the user can draft the next question.
  • Do: Upload what `filesPicked` gives you. The component owns the policy (`svCheckAttachments`); a refused file stays visible with its reason and never travels.
  • Don't: Do not intercept Enter yourself. The component already ignores the Enter that commits an IME composition — Japanese, Chinese and Korean input would otherwise send half a word.
  • Tip: A slash command with `insert` replaces the `/token` with text; one without becomes a chip that travels with `submitted`.

Accessibility

  • The text box names itself and drives the `/` list with `aria-activedescendant`; arrows move, Enter or Tab chooses, Escape dismisses.
  • The model menu is a `menu` of `menuitemradio` items with roving focus; Escape returns focus to its button.
  • The mic reports `aria-pressed`, and every icon button has an accessible name.

Feedback on Prompt Input

Spotted a gap in this page, or something that didn't work as described? Comments are GitHub Discussions in the public styloviz/community repo, so posting needs a GitHub account.

Loads giscus.app and GitHub — nothing is fetched until you click.