# Sender Message Input Component
# Features
A message input component for user input and message sending, supporting the following features:
- Auto-resizing text input area
- Support for two layout variants (default and vertical layout)
- Built-in speech recognition (using browser Web Speech API)
- Customizable header and footer content
- Trigger character popup functionality
- Multiple submission methods (Enter/Shift+Enter)
- Built-in action buttons (send, cancel, clear, voice)
- Disabled and readonly state support
# Usage Examples
# Basic Usage
Basic message input component usage with default layout and basic functionality.
# Component Instance Methods
Example of using component instance method calls.
# Different Layout Variants
Configure different layout styles through the variant
property.
# Speech Recognition
Built-in speech recognition functionality can be enabled through the allowSpeech
property. It uses the browser's native speech recognition API. When using in Google Chrome, it requires a secure environment to work properly.
Note
If you don't want to use the built-in speech recognition functionality, you can listen to recording status through the @recording-change
event and implement your own speech recognition.
You can also call through the component ref instance:
senderRef.value.startRecognition()
Trigger start recordingsenderRef.value.stopRecognition()
Trigger stop recording
# Trigger Character Popup
Configure trigger characters through triggerStrings
. When these characters are entered, a popup will be displayed.
# Custom Action Buttons
Customize action buttons through the action-list
slot.
# Custom Header and Footer
Note
To display the header, you need to manually call the component's openHeader
method when mounting
Customize header and footer content through the header
and footer
slots.
# Custom Input Styles
Customize input styles conveniently through input-style
prop
# Attributes
Parameter | Description | Type | Default |
---|---|---|---|
value / v-model | Binding value | String | '' |
placeholder | Input placeholder text | String | 'Please enter content' |
autoSize | Input auto-resize configuration | Object | { minRows: 1, maxRows: 6 } |
readOnly | Whether readonly | Boolean | false |
disabled | Whether disabled | Boolean | false |
loading | Whether to show loading state | Boolean | false |
clearable | Whether to show clear button | Boolean | false |
allowSpeech | Whether to enable speech input | Boolean | false |
submitType | Submit method, 'enter' or 'shiftEnter' | String | 'enter' |
headerAnimationTimer | Header animation duration (ms) | Number | 300 |
inputWidth | Input width | String | '100%' |
variant | Layout variant, 'default' or 'updown' | String | 'default' |
showUpdown | Whether to show action bar in updown variant | Boolean | true |
submitBtnDisabled | Manually control submit button disabled state | Boolean | - |
inputStyle | Input style pass-through | Object | {} |
triggerStrings | Trigger character array for popup | Array | [] |
triggerPopoverVisible | Popover display state | Boolean | false |
triggerPopoverWidth | Popover width | String | 'fit-content' |
triggerPopoverLeft | Popover left offset | String | '0px' |
triggerPopoverOffset | Popover offset | Number | 8 |
triggerPopoverPlacement | Popover placement | String | 'top-start' |
# Methods
Method Name | Description | Parameters | Return Value |
---|---|---|---|
blur | Remove focus | - | - |
focus | Get focus | type: 'all'/'start'/'end' | - |
focusToStart | Focus to text start | - | - |
focusToEnd | Focus to text end | - | - |
startRecognition | Start speech recognition | - | - |
stopRecognition | Stop speech recognition | - | - |
submit | Trigger submit | - | - |
cancel | Trigger cancel | - | - |
clear | Clear content | - | - |
openHeader | Open header | - | - |
closeHeader | Close header | - | - |
startLoading | Start loading | - | - |
stopLoading | Stop loading | - | - |
insertTextAtCaret | Insert text at cursor position | text | - |
# Events
Event Name | Description | Callback Parameters |
---|---|---|
input | Triggered when input value changes | (value: string) |
submit | Triggered when submit button is clicked or submit shortcut is pressed | (value: string) |
cancel | Triggered when cancel button is clicked | (value: string) |
recording-change | Triggered when speech recognition status changes | (isRecording: boolean) |
trigger | Triggered when trigger character status changes | { oldValue: string, newValue: string, triggerString: string, isOpen: boolean, cursorPosition?: number } |
update:triggerPopoverVisible | Triggered when popover visibility changes | (visible: boolean) |
# Slots
Slot Name | Description | Scope Parameters |
---|---|---|
header | Custom header content | - |
footer | Custom footer content | - |
prefix | Input prefix content | - |
action-list | Custom action button list | - |
trigger-popover | Trigger character popup content | { triggerString: string, readonly: boolean } |