Prompt Input
ProThe 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
Usage example — open the gallery for the full interactive demo.
Pro
An interactive demo for this component lives in the gallery.
Open live demoMore examples
Everything on
Compact pill
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
| Name | Type | Default | Description |
|---|---|---|---|
| value | string (two-way) | '' | The draft. Two-way. |
| placeholder | string | null | null | Placeholder text; `null` uses the `placeholderPanel` label. |
| layout | SvPromptInputLayout | 'block' | `block` (multi-line box, toolbar underneath) or `pill` (one compact row). |
| busy | boolean | false | A reply is in flight: the send button becomes stop, and Enter does nothing. |
| disabled | boolean | false | Disable the whole composer. |
| models | readonly ChatAiModel[] | [] | Models offered by the picker. Empty hides the picker. |
| selectedModel | ChatAiModel | null (two-way) | null | The chosen model. Two-way. |
| attachable | boolean | false | Show the attach button. The host owns the upload; the component owns the policy. |
| attachments | readonly 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. |
| attachmentLimits | SvChatAttachmentLimits | null | null | Count, size and type limits for attachments (`svCheckAttachments`). `null` uses the defaults. |
| slashCommands | readonly SvSlashCommand[] | [] | Commands offered when the message starts with `/`. Empty turns the menu off. |
| voice | boolean | false | Show the mic toggle. Wire `micToggle` to your recorder. |
| listening | boolean | false | The recorder is listening — the mic shows pressed. |
| labels | Partial<SvAiChatProLabels> | {} | Per-instance text, merged over the registry's `aiChatPro` labels. |
Outputs
| Event | Payload type | Description |
|---|---|---|
| submitted | SvPromptSubmit | The user sent the draft. The box clears itself afterwards. |
| stop | void | The user pressed stop while `busy`. Abort your request here. |
| filesPicked | readonly File[] | Files the user picked that passed the policy — upload these. |
| slashCommand | SvSlashCommand | A command was chosen from the `/` menu. |
| micToggle | boolean | The mic was pressed. The payload is the state asked for: `true` to start listening. |
| valueChange | string | Emits the new `value` whenever it changes — the output half of `[(value)]`. |
| selectedModelChange | ChatAiModel | null | Emits the new `selectedModel` whenever it changes — the output half of `[(selectedModel)]`. |
| attachmentsChange | readonly 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.