Skip to content
🌏 Translated with the assistance of DeepSeek and ChatGPT

Prompt ​

A rich input component for AI conversations, supporting adaptive multi-line input, chip mentions, attachment upload, speech input and a customizable toolbar.

Full Example ​

The input is kept by modelValue for the text and by content for the chips; chipConfig configures the mention triggers and candidates (see PromptChip), uploadConfig enables the attachment upload (see PromptAttachment), and speechConfig enables the speech input (see PromptSpeech). The toolbar is composed through the start, end and send slots: PromptAction, PromptSwitch and PromptSelect provide the actions, the switches and the dropdown selection (see PromptAction), and PromptSend provides the send entry (see PromptSend).

Speech Mode
Prompt State
Ask anything, type @ or / to mention
0 / 200
Hide source code

Caret and Text Operations ​

Beyond focus and blur, the ref exposes methods that operate on the input directly: setCaret and placeCaretAtEnd move the caret, select selects everything, insertText inserts text at the caret, removeText removes characters before it, and insertChip inserts a chip (see PromptChip). disabled and readonly only block user input; these methods still work, consistent with a native input. The following example turns them all into buttons.

value: Hello Pixelium
Hide source code

API ​

PromptCounterConfig ​

AttributeTypeOptionalDefaultDescriptionVersion
maxLengthnumberTrueThe maximum length of the input.0.2.1
countGraphemes(value: string) => numberTrueCustom function that counts the length of the text.0.2.1
sliceGraphemes(value: string, limit: number) => stringTrueCustom function that slices the text with a length limit.0.2.1

PromptProps ​

AttributeTypeOptionalDefaultDescriptionVersion
modelValuestring | nullTrueThe input text of Prompt.0.2.1
defaultValuestring | nullTrueThe initial input text in uncontrolled mode.0.2.1
contentPromptContent | nullTrueThe input content of Prompt, holding both text and chip segments.0.2.1
defaultContentPromptContent | nullTrueThe initial input content in uncontrolled mode.0.2.1
shape'rect' | 'round'True'round'The appearance shape of Prompt.0.2.1
borderRadiusNumberOrPercentage | NumberOrPercentage[]TrueThe corner radius of Prompt, accepting numbers, percentages or an array for the four corners.0.2.1
disabledbooleanTruefalseWhether Prompt is disabled.0.2.1
readonlybooleanTruefalseWhether Prompt is read only.0.2.1
loadingbooleanTruefalseWhether Prompt is submitting.0.2.1
cancellablebooleanTruetrueWhether the submission can be aborted while Prompt is loading.0.2.1
placeholderstringTrueThe placeholder text shown while the input is empty.0.2.1
autoSizebooleanTruetrueWhether the input area grows automatically with the content.0.2.1
minRownumberTrue1The minimum number of rows of the input area.0.2.1
maxRownumberTrueInfinityThe maximum number of rows of the input area.0.2.1
counterConfigPromptCounterConfigTrueThe configuration of the word counter; the counter area is shown once it is given.0.2.1
submitKeyPromptSubmitKeyTrue'ctrl+enter'The key combination that submits the content.0.2.1
newlineKeyPromptSubmitKeyTrue'enter'The key combination that inserts a new line.0.2.1
requireContentbooleanTruetrueWhether submitting is forbidden while the input is empty.0.2.1
clearOnSubmitbooleanTruefalseWhether the input is cleared after a submission.0.2.1
uploadConfigPromptUploadConfigTrueThe configuration of the attachment upload; the attachment ability is enabled once it is given. See PromptAttachment.0.2.1
speechConfigPromptSpeechConfigTrueThe configuration of the speech input; the speech ability is enabled once it is given. See PromptSpeech.0.2.1
chipConfigPromptChipConfigTrueThe configuration of the chip mentions; see PromptChip.0.2.1

PromptEvents ​

EventParameterDescriptionVersion
update:modelValuevalue: stringTriggered when the input text changes.0.2.1
inputvalue: string, e: EventTriggered while typing in the input area.0.2.1
changevalue: string, e: Event | undefinedTriggered when the input area loses focus after the content changed.0.2.1
submitvalue: string, e: KeyboardEvent | MouseEvent | undefinedTriggered on submission, fired by the send entry, the submit key and the submit method alike.0.2.1
cancele: MouseEvent | undefinedTriggered when the abort entry is clicked while Prompt is loading.0.2.1
clearvalue: stringTriggered when the input is cleared.0.2.1
focuse: FocusEventTriggered when the input area gains focus.0.2.1
blure: FocusEventTriggered when the input area loses focus.0.2.1
keydowne: KeyboardEventTriggered when a key is pressed in the input area.0.2.1
pastee: ClipboardEventTriggered when content is pasted into the input area.0.2.1
update:contentcontent: PromptContentTriggered when the text or the chips of the content change.0.2.1
chipAddchip: PromptChipTriggered when a chip is inserted.0.2.1
chipRemovechip: PromptChipTriggered when a chip is removed.0.2.1
triggerpayload: PromptTriggerPayloadTriggered when a mention trigger character is typed.0.2.1
selectoption: string | PromptOption, e: MouseEvent | KeyboardEventTriggered when an option is chosen from the candidate list.0.2.1

PromptSlots ​

SlotParameterDescriptionVersion
attachmentupload: PromptUploadScopeThe attachment area, holding PromptAttachment and other attachment content; its scope provides the attachment actions, and the actions run on every matching file when no file is given.0.2.1
footerupload: PromptUploadScope, send: PromptSendScope, speech: PromptSpeechScopeThe bottom row area, composed of the start, end and send slots by default and replaced as a whole when overridden; its scope provides the attachment actions, and the actions run on every matching file when no file is given.0.2.1
startupload: PromptUploadScope, send: PromptSendScope, speech: PromptSpeechScopeThe leading area of the toolbar, whose scope provides the attachment actions, and the actions run on every matching file when no file is given.0.2.1
endupload: PromptUploadScope, send: PromptSendScope, speech: PromptSpeechScopeThe trailing area of the toolbar, placed before the send entry, whose scope provides the attachment actions, and the actions run on every matching file when no file is given.0.2.1
sendupload: PromptUploadScope, send: PromptSendScope, speech: PromptSpeechScopeThe send entry area, whose scope provides the attachment actions, and the actions run on every matching file when no file is given.0.2.1
countvalue: string, count: number, maxLength: number | undefinedThe counter area.0.2.1
chip-optionoption: string | PromptOptionThe content of an option in the candidate list.0.2.1
chip-group-labeloption: PromptGroupOptionThe content of a group label in the candidate list.0.2.1
speech-panelspeech: PromptSpeechScopeThe speech recording panel area, replacing the internal PromptSpeechPanel.0.2.1
speech-cancelspeech: PromptSpeechScopeThe cancel entry of the speech recording panel.0.2.1
speech-visualizerspeech: PromptSpeechScopeThe visualizer area of the speech recording panel.0.2.1
speech-textspeech: PromptSpeechScopeThe live text area of the speech recognition.0.2.1
speech-acceptspeech: PromptSpeechScopeThe confirm entry of the speech recording panel.0.2.1

PromptExpose ​

AttributeTypeOptionalDefaultDescriptionVersion
focus() => voidFalseFocuses the input area.0.2.1
blur() => voidFalseRemoves the focus from the input area.0.2.1
clear() => voidFalseClears the input.0.2.1
submit() => voidFalseSubmits the current input.0.2.1
select() => voidFalseSelects everything inside the input area.0.2.1
setCaret(position: PromptCaretPosition) => voidFalse0.2.1
placeCaretAtEnd() => voidFalseMoves the caret to the end of the input.0.2.1
insertChip(chip: PromptChip) => voidFalseInserts a chip at the caret.0.2.1
removeChip(id: number | string | symbol) => voidFalseRemoves the chip with the given id.0.2.1
insertText(text: string) => voidFalseInserts text at the caret.0.2.1
removeText(length: number) => voidFalseRemoves length characters before the caret; a chip covered by the range is removed as a whole.0.2.1
getContent() => PromptContentFalseReads the current input content.0.2.1
setContent(content: PromptContent) => voidFalseOverwrites the current input content.0.2.1

PromptSubmitModifier ​

ts
export type PromptSubmitModifier =
	| 'ctrl'
	| 'control'
	| 'meta'
	| 'cmd'
	| 'command'
	| 'alt'
	| 'option'
	| 'shift'

PromptSubmitKey ​

ts
type SubmitKeyPrefix =
	| PromptSubmitModifier
	| `${PromptSubmitModifier}+${PromptSubmitModifier}`
	| `${PromptSubmitModifier}+${PromptSubmitModifier}+${PromptSubmitModifier}`

export type PromptSubmitKey = 'enter' | `${SubmitKeyPrefix}+enter`

PromptSegment ​

ts
export type PromptSegment = { type: 'text'; text: string } | { type: 'chip'; chip: PromptChip }

PromptContent ​

ts
export type PromptContent = PromptSegment[]

PromptCaretPosition ​

ts
export type PromptCaretPosition = 'start' | 'end' | number

EmitEvent ​

ts
export type EmitEvent<T extends Record<string, any>> = {
	[K in keyof T as `on${Capitalize<K & string>}`]?: (...args: T[K]) => void
}

RestAttrs ​

ts
import type { StyleValue } from 'vue'

export type VueClassValue = string | Record<string, any> | VueClassValue[]
export type VueStyleValue = StyleValue

export type RestAttrs = {
	style?: VueStyleValue | null
	class?: VueClassValue | null
	[x: string]: any
}