Calm motion: animations on this site only fade, with no movement
Prompt input
The text box of a chat with an assistant
The box where a person writes to an assistant. It grows with the text, sends on Enter, and turns its send button into a stop button while a reply comes in. Put the messages above it with BlessBubble in a BlessMessageScroller, and a reply that comes in part by part with BlessStreamingText.
Basic
- Enter sends, and Shift+Enter adds a line. Enter that picks a word in an input method (for example for Japanese or Chinese) does not send.
sendgets{ text, files }, with the text trimmed. Then the box is empty again. The box does not send when it is empty, when it isdisabled, or while it isbusy.v-modelholds the text, so the app can keep a draft.v-model:filesholds the files.- The box grows with the text up to
max-rowslines (default 8), and then it scrolls. It uses CSSfield-sizing. In a browser without it, the box keeps one line and scrolls. busyturns the send button into a stop button, which emitsstop. The text box stays open, so a person can write the next message.attachshows a button that opens the file picker. Set it to a text such as"image/*"to limit the file types. Files can also be dropped on the box. Each file shows as an attachment chip that a person can remove.- The
actionsslot puts more buttons in the bar, for example a model picker. - Change the words with
labelsor a label pack:label(the name of the box for screen readers),placeholder,send,stop,attach, andremove.
Usage
ts
import { BlessPromptInput } from "blessing-ui";API
Props
| Name | Type | Default | Description |
|---|---|---|---|
busy | boolean | — | a reply is coming in: the send button becomes a stop button |
disabled | boolean | — | |
attach | string | boolean | — | show the attach button; a text sets the file types, as `accept` on a file input |
maxRows | number | 8 | the most lines before the box scrolls |
labels | Partial<{ label: string; placeholder: string; send: string; stop: string; attach: string; remove: string; }> | — | |
modelValue | string | "" | |
files | File[] | [] |
Events
| Name | Payload | Description |
|---|---|---|
update:modelValue | [value: string] | |
stop | [] | |
send | [message: { text: string; files: File[]; }] | |
update:files | [value: File[]] |
Slots
| Name | Scope | Description |
|---|---|---|
actions | — |