Skip to content

Mentions ​

A member mention input triggered by typing @, supporting filtering, multiline input and a select callback.

Basic usage ​

vue
<script setup>
import { ref } from 'vue'
const value = ref('')
const members = [
  { label: 'Ink wash', value: 'ink' },
  { label: 'Blank space', value: 'blank' },
]
</script>

<template>
  <lh-mentions v-model="value" :options="members" />
</template>

After typing @ the suggestion panel opens, and further typing filters by label. What gets written back on selection is the label (a human-readable @Ink wash ); the machine-readable identifier value is handed to the business layer via the select event.

Multiline ​

vue
<template>
  <lh-mentions v-model="value" :options="members" multiline />
</template>

multiline swaps the single-line input for a textarea.

Trigger character ​

vue
<template>
  <lh-mentions v-model="value" :options="members" prefix="#" />
</template>

prefix defaults to '@'; a pseudo-prefix directly attached to an ASCII word character (such as user@ in an email address) does not trigger.

Props ​

PropDescriptionTypeDefault
modelValueText content (v-model)string''
optionsSuggested membersLhMentionOption[][]
prefixTrigger characterstring'@'
placeholderPlaceholder hint (defaults to the mentions.placeholder locale message)string—
placeholderStylePlaceholder style (replaces ::placeholder)string—
disabledDisable the componentbooleanfalse
multilineMultiline textareabooleanfalse
ariaLabelAccessible namestring—
customClassCustom class namestring—
sxQuick layout propsLhSxProps—

Slots ​

SlotDescription
emptyEmpty state when nothing matches (default text comes from the mentions.noMatch locale message)

Events ​

EventDescriptionParameters
update:modelValueWrites back after input or selection(value: string)
changeText changed(value: string)
selectA mention item was selected(option: LhMentionOption)

Methods (defineExpose) ​

MethodDescription
updateContextManually refresh the cursor context
closeClose the suggestion panel

Platform differences ​

CapabilityH5Mini Program
Dropdown positioningroot-portal + two-frame measurement (same as select)Alipay uses root-portal or in-page fixed depending on the base library version; Douyin uses in-page fixed
Cursor contextNative selectionStart (mentions can be triggered in the middle of the text)The cursor position is unavailable and is approximated as the end of the text — triggering a mention in the middle of existing text does not work and degrades to appending at the end
Keyboard navigation / EscArrow keys move the highlight, Enter selects, Esc closesNo keyboard events; selection by click only
Cursor position after selectionLands exactly after the mentionAfter the controlled write-back the cursor sits at the end