Skip to content

Sender Input Box 💭

📌 Warning

Added in version 1.1.6

  • Variant Up-Down Structure
  • Custom bottom #footer slot
  • Custom directive Popover and callback event for triggering the directive

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

Introduction

Sender is an input box component for chat scenarios. It features rich interactive functions and customization options. It supports voice input, clearing input content, multiple submission methods, and allows users to customize the header, prefix, and action list. The component also provides focus control, submission callbacks, and more, to meet diverse input scenarios.

Code Examples

Basic Usage

This is a Sender 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

📌 Warning

Before version 1.0.81, when using custom slots, the built-in action buttons would be sacrificed. In version 1.0.81, we launched streaming request hooks that allow users to better control streaming requests, thus better defining the #action-list slot. For details, please check our project template's main request library, comparable to Axios hook-fetch.

This friendly reminder update time: 2025-07-05

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

Trigger Directive

Input box with built-in directive popover for convenient directive operations

💌 Info

  • Set directive trigger characters through the triggerStrings property, type is a character array ['/', '@']
  • Control whether the directive popover is visible through v-model binding triggerPopoverVisible property

v-model:trigger-popover-visible="triggerVisible"

  • Set directive popover width through triggerPopoverWidth property, default 'fit-content'
  • Set directive popover distance from left through triggerPopoverLeft property, default '0px'
  • Set distance between directive popover and input through triggerPopoverOffset property, default 8
  • Set directive popover position through triggerPopoverPlacement property, same as el-popover's placement property, default 'top-start'

Values 'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end' | 'right' | 'right-start' | 'right-end'

  • @trigger Set callback method for directive popover show/hide changes

💡 Tip

  • @trigger When you want to do something when a directive is triggered but don't want the built-in popover style, you can not use v-model:trigger-popover-visible="triggerVisible", so the built-in popover won't appear

Custom Directive Popover

💡 Tip

Custom popover content. If you only need to match the beginning of a certain character, you can use this component.

📌 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

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

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
triggerTriggered when the directive popover changes.interface TriggerEvent{oldValue: string; newValue: string; isOpen: boolean; }

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.

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.