Skip to content

MentionSender Mention Input Box ๐Ÿฆฅ โ€‹

Introduction โ€‹

MentionSender is an input box component for chat scenarios.

๐Ÿ“Œ Warning

Its functionality is basically the same as the Sender component. The only difference is the properties and methods related to the directive popover. Click here to quickly understand the difference ๐Ÿ‘‰ Directive Difference

Currently, we do not plan to combine the directive features of MentionSender and Sender into one, and we distinguish them only by component.

Code Examples โ€‹

Basic Usage โ€‹

This is a MentionSender input component, the simplest usage example.

Placeholder โ€‹

You can set the input placeholder through the placeholder attribute.

Two-way Binding (Unbound, value will not change) โ€‹

You can bind the component's value property through v-model.

๐Ÿ“Œ Warning

  • When submitting, content is required for submission to proceed.
  • When content is empty, the submit button will be disabled, and using component instance submission will fail.

๐Ÿ’Œ Info

  • Through the v-model attribute, you can automatically bind the input value. No need to assign data to v-model.
  • Through the @submit event, you can trigger the input submission event, which returns a value parameter where you can handle the submitted data.
  • Through the @cancel event, you can trigger the loading button click event. Here you can abort the submission operation.

You can also call through the component ref instance object

  • senderRef.value.submit() Trigger submission
  • senderRef.value.cancel() Trigger cancel
  • senderRef.value.clear() Reset input value

Submit Button Disabled State โ€‹

This is the built-in disable logic:
Custom disable logic:

You can customize whether to disable the send button through submit-btn-disabled. When disabled, the component instance's submit method will fail.

๐Ÿ“Œ Warning

The built-in send button is bound to v-model, so when the v-model bound value is empty, the send button will be in disabled state.

However, there is such a scenario. The user uploaded a file but didn't input content, at this time, the send button is still in disabled state. So, for decoupling the disable logic, the component provides the submit-btn-disabled attribute for autonomous control of the send button's disabled state.

When customizing #action-list, this attribute also takes effect for submit events.

Custom Max and Min Rows โ€‹

You can set the minimum and maximum display rows for the input through autosize. autosize is an object with default value { minRows: 1, maxRows: 6 }. When exceeding the maximum rows, the input will automatically show a scrollbar.

Various States of the Input Component โ€‹

You can implement component states through simple properties

๐Ÿ’Œ Info

  • Through the loading property, you can control whether the input is loading.
  • Through the readOnly property, you can control whether the input is editable.
  • Through the disabled property, you can control whether the input is disabled.
  • Through the clearable property, you can control whether the input shows a delete button for clearing.
  • Through the inputWidth property, you can control the input width. Default is 100%.

Submission Methods โ€‹

Control line breaks and submit mode with submitType. Default is 'enter', i.e., press Enter to submit, 'shift + Enter' for a new line.

๐Ÿ’Œ Info

  • submitType='enter' sets Enter to submit, 'shift + Enter' for a new line.
  • submitType='shiftEnter' sets 'shift + Enter' to submit, Enter for a new line.
  • submitType='cmdOrCtrlEnter' sets 'cmd + Enter' or 'ctrl + Enter' to submit, Enter for a new line.
  • submitType='altEnter' sets 'alt + Enter' to submit, Enter for a new line.

Speech Recognition โ€‹

๐Ÿ“Œ Warning

Built-in browser speech recognition API. You can use the useRecord hook for easier integration and control of built-in speech recognition.

Built-in voice recognition:
Custom voice recognition:

Built-in voice recognition functionality, enable it through the allowSpeech property. It calls the browser's native voice recognition API, and when used in Google Chrome, it needs to be in a ๐Ÿช„magic environment to work properly.

๐Ÿ’Œ Info

If you don't want to use the built-in voice recognition functionality, you can listen to the recording state through the @recording-change event and implement voice recognition functionality yourself.

You can also call through the component ref instance object

  • senderRef.value.startRecognition() Trigger start recording
  • senderRef.value.stopRecognition() Trigger stop recording

Variant - Vertical Style โ€‹

Deep Thinking
Left is custom prefix, right is custom action list

Set the input variant through the variant property. Default 'default' | Up-down structure 'updown'

This property changes the left-right structure input into an up-down structure input. The top is the input box, and the bottom is the built-in prefix and action list bar

Custom Action List โ€‹

Use the #action-list slot to customize the input action list content.

๐Ÿ’Œ Info

When you use the #action-list slot, the built-in input action buttons will be hidden. You can combine it with component instance methods to implement richer operations.

Custom Prefix โ€‹

Use the #prefix slot to customize the input prefix content.

Custom Header โ€‹

Use the #header slot to customize the input header content.

๐Ÿ’Œ Info

Control header container expand/collapse through component instance

  • senderRef.value.openHeader() Open header container
  • senderRef.value.closeHeader() Close header container

Custom Input Box Style โ€‹

Deep Thinking

Pass through input styles conveniently through input-style

Input Focus Control โ€‹

Control focus through ref option.

๐Ÿ’Œ Info

Control through component instance

  • senderRef.value.focus('all') Focus on entire text (default)
  • senderRef.value.focus('start') Focus on text beginning
  • senderRef.value.focus('end') Focus on text end
  • senderRef.value.blur() Remove focus

Mention Directive Usage (Difference from Sender Component) โ€‹

๐Ÿ“Œ Warning

Below are the properties and methods related to directives that are different from the Sender component. Please pay attention to the usage differences.

๐Ÿ’Œ If you need to trigger a mention directive list in the middle of a content, you can use this component.

This warm tip was last updated: 2025-04-16

Custom Trigger Directive Array โ€‹

  • Through the options property, you can pass an array to define the mention option list.
  • Through the triggerStrings property, the prefix of the trigger field. This is different from the Sender component, where the string length must be exactly 1.
ts
// Type definition for options mention option list
interface MentionOption {
  value: string
  label?: string
  disabled?: boolean
  [key: string]: any
}

๐Ÿ’Œ Info

Setting only the options property cannot enable the mention functionality. The triggerStrings property is needed to enable the mention functionality.

Custom Trigger Directive String โ€‹

Trigger field through the triggerStrings property. This is different from the Sender component, where the string length must be exactly 1. The type is Array<string>.

If you need to trigger through multiple strings, you can combine it with the @search event to control the popover content display.

๐Ÿ’Œ Info

Setting only the options property cannot enable the mention functionality. The triggerStrings property is needed to enable the mention functionality.

Custom Trigger Directive Separator โ€‹

Character used to split mentions. The string length must be exactly 1, default is ' '.

Trigger Directive Loading โ€‹

Set the loading state of the mention option list through the triggerLoading property. The triggerLoading property defaults to false, meaning no loading state is displayed by default.

Custom Trigger Directive Filter โ€‹

Customize the filter option logic through filter-option, using a method that returns true or false to control the option filtering results. You can also understand it as the search filtering logic.

The type is (pattern: string, option: MentionOption) => boolean

Whole Deletion โ€‹

  • Set the whole property to true, when you press the backspace key, the mention area here will be deleted as a whole.

  • Set the check-is-whole property to customize the check logic. When you need to do multiple conditions, you can use the check-is-whole property to customize the check logic.

  • The check-is-whole property is not an event, the type is (pattern: string, prefix: string) => boolean, returning true means the match is successful and will be deleted as a whole, returning false means the match fails and will not be deleted as a whole. Default is true

Trigger Directive Popover Placement โ€‹

Set the popup direction through trigger-popover-placement. Default is 'top', can be set to 'bottom'. Currently only supports 'top' and 'bottom' two types.

Trigger Directive Popover Offset โ€‹

You can set the offset of the popover from the window through the triggerPopoverOffset property. Default value is 20, representing 20px.

Popover Slots โ€‹

๐Ÿ’Œ Info

  • Supports #trigger-label for customizing the label content, i.e., how each data item is displayed
  • Supports #trigger-loading for customizing the loading state, which is shown when triggerLoading is true
  • Supports #trigger-header for customizing the content at the top of the dropdown list
  • Supports #trigger-footer for customizing the content at the bottom of the dropdown list

๐Ÿ“Œ Warning

๐Ÿ’Œ Friendly Reminder: Since V1.3.1, the component ref can access the popover open state property popoverVisible and the built-in input instance inputInstance.

This means:

  1. You can perform some logic based on whether the popover is open.
  2. The popover can support richer custom events.

This reminder date: 2025-07-21

Search Event โ€‹

Select Event โ€‹

Triggered when user selects an option

Props โ€‹

NameTypeRequiredDefaultDescription
v-modelStringNo''Bound value of the input box, use v-model for two-way binding.
placeholderStringNo''Placeholder text for the input box.
auto-sizeObjectNo{ minRows:1, maxRows:6 }Set the minimum and maximum number of visible rows for the input box.
read-onlyBooleanNofalseWhether the input box is read-only.
disabledBooleanNofalseWhether the input box is disabled.
submitBtnDisabledBoolean | undefinedNoundefinedDisable the built-in send button. (Note the usage scenario)
loadingBooleanNofalseWhether to show the loading state. When true, the input box will display a loading animation.
clearableBooleanNofalseWhether the input box can be cleared. Shows the default clear button.
allowSpeechBooleanNofalseWhether to allow voice input. Shows the built-in speech recognition button by default, using the browser's built-in speech recognition API.
submitTypeStringNo'enter'Submission method. Supports 'shiftEnter' (submit with Shift + Enter), 'cmdOrCtrlEnter' (submit with Command + Enter or Ctrl + Enter), 'altEnter' (submit with Alt + Enter).
headerAnimationTimerNumberNo300Custom header display duration in ms.
inputWidthStringNo'100%'Width of the input box.
variantStringNo'default'Variant type of the input box. Supports 'default', 'updown'.
showUpdownBooleanNotrueWhether to show the built-in style when the variant is updown.
inputStyleObjectNo{}Style of the input box.
triggerStringsstring[]No[]String array for trigger directives.
triggerPopoverVisibleBooleanNofalseWhether the popover for the trigger directive is visible. Control with v-model:triggerPopoverVisible.
triggerPopoverWidthStringNo'fit-content'Width of the popover for the trigger directive. Supports percentage and other CSS units.
triggerPopoverLeftStringNo'0px'Left margin of the popover for the trigger directive. Supports percentage and other CSS units.
triggerPopoverOffsetNumberNo8Offset of the popover for the trigger directive. Must be a number, unit is px.
triggerPopoverPlacementStringNo'top-start'Placement of the popover for the trigger directive. Values: 'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end' | 'right' | 'right-start' | 'right-end'

Events โ€‹

Event NameDescriptionCallback Parameter
submitTriggered when the built-in submit button is clicked.None
cancelTriggered when the built-in loading button is clicked.None
recordingChangeTriggered when the built-in speech recognition state changes.None
selectTriggered when the trigger field is pressed.option: MentionOption
searchTriggered when the user selects an option.searchValue: string, prefix: string

Ref Instance Methods โ€‹

NameTypeDescription
openHeaderFunctionOpen the custom header of the input box.
closeHeaderFunctionClose the custom header of the input box.
clearFunctionClear the content of the input box.
blurFunctionRemove focus from the input box.
focusFunctionFocus the input box. By default, focus('all') selects all text, focus('start') focuses at the start, focus('end') focuses at the end.
submitFunctionSubmit the input content.
cancelFunctionCancel the loading state.
startRecognitionFunctionStart speech recognition.
stopRecognitionFunctionStop speech recognition.
popoverVisibleBooleanPopover visibility for the trigger directive.
inputInstanceObjectInput box instance.

Slots โ€‹

Slot NameParameterTypeDescription
#header-SlotFor customizing the header content.
#prefix-SlotFor customizing the prefix content.
#action-list-SlotFor customizing the action list.
#footer-SlotFor customizing the footer content.
#trigger-label#trigger-label={ item, index }SlotFor customizing the popover label.
#trigger-loading-SlotFor customizing the popover loading state.
#trigger-header-SlotFor customizing the popover header.
#trigger-footer-SlotFor customizing the popover footer.

Features โ€‹

  1. Focus Control: Supports setting focus to the start, end, or selecting all text, and can also remove focus.
  2. Custom Content: Provides slots for header, prefix, and action list, allowing users to customize these parts.
  3. Submission Function: Supports submitting input with Shift + Enter, and allows custom actions after submission.
  4. Loading State: Can display a loading state to simulate the submission process.
  5. Voice Input: Supports voice input for more convenient input.
  6. Clear Function: The input box can be cleared for easy re-entry.