Skip to content

Mention

Used to quickly select and insert mention content via trigger characters (@, #, etc.) in inputs or textareas. Widely used in comments, private messages, and task collaboration scenarios.

Basic Usage

Bind values using v-model and configure candidate lists with options. Type @ in the input to trigger the suggestion panel.

Current value:

Basic Usage

Avatar Options

Add an avatar field to each option to display user avatars in the dropdown, combined with description to show additional info.

Options with Avatars

Grouped Options

Set the group field to categorize options into groups. Options with the same group value are automatically merged into the same section.

Grouped Options

Multiple Triggers

Specify multiple trigger characters via triggers, such as supporting both @ for people and # for tags. Switch option sources dynamically using the search event.

Current value:

Multiple Triggers

Async Loading

Listen to the search event to initiate network requests. Use :loading="true" to show a loading indicator, then update options when data returns.

Async Loading

Textarea Mode

Set type="textarea" to use mention functionality in a multi-line textarea, supporting all mention features.

Textarea Mode

Custom Filter

Customize filtering logic via the filter-option prop, for example to support Pinyin search. Set to false to disable filtering and display all options.

Custom Filter (Pinyin Support)

Custom Option Rendering

Customize option display content using the #option slot. Slot parameters include option and keyword.

Custom Option Rendering

Word Count

Display character count in real-time when used with maxlength and show-word-limit.

0 / 100
Word Count

Disabled

Set disabled to disable the component. Actions are prevented and the suggestion panel won't trigger.

Disabled

Usage in Nuxt

Mention is fully compatible with Nuxt 3/4 and has been verified in SSR environments. The initial modelValue renders as static text on the server, and interactions activate after client-side hydration.

Nuxt Usage

SSR Considerations:

  • modelValue initial text renders correctly on server
  • ✅ Disabled and Readonly states effect on server
  • ✅ Multi-size and custom classes render correctly on server
  • ⚠️ Dropdown and triggers activate after client-side Hydration
  • 💡 Use Nuxt's <ClientOnly> to downgrade interactions to client-side only if needed

SSR Performance

In SSR scenarios, Mention's initial render only includes the input itself. The dropdown panel is not server-rendered (v-show="false"), minimizing impact on first-paint performance.

API

Props

PropDescriptionTypeDefault
model-value / v-modelBinding valuestring''
optionsCandidate options listMentionOption[][]
triggersTrigger charactersstring[]['@']
typeInput type'input' | 'textarea''input'
placementDropdown direction'top' | 'bottom''bottom'
placeholderPlaceholder textstring
disabledWhether disabledbooleanfalse
readonlyWhether readonlybooleanfalse
sizeSize'large' | 'default' | 'small''default'
maxlengthMax input lengthnumber
clearableWhether clearablebooleanfalse
show-word-limitWhether to show word limitbooleanfalse
prefix-iconPrefix iconComponent
suffix-iconSuffix iconComponent
filter-optionCustom filter function, set to false to disable((keyword, option) => boolean) | false
loadingWhether loadingbooleanfalse
loading-textLoading textstring'Loading...'
no-data-textNo data textstring'No Data'
teleportedMount dropdown to bodybooleantrue
popper-classCustom dropdown classstring''
splitSeparator appended after selectionstring' '
whole-wordWhether to insert as whole wordbooleanfalse
autofocusAuto focusbooleanfalse
rowsTextarea rowsnumber3
debounceSearch debounce delay (ms)number100
validate-eventWhether to trigger form validationbooleantrue
theme-overridesTheme override variablesComponentThemeVars

MentionOption

FieldDescriptionType
valueUnique identifier (required)string
labelDisplay labelstring
disabledWhether disabledboolean
avatarAvatar URLstring
descriptionDescription infostring
groupGroup namestring

Events

EventDescriptionParameters
update:modelValueTriggered on value change(value: string) => void
inputTriggered on input(value: string) => void
changeTriggered on blur(value: string) => void
focusTriggered on focus(event: FocusEvent) => void
blurTriggered on blur(event: FocusEvent) => void
clearTriggered on clear() => void
searchTriggered on search(keyword: string, trigger: string) => void
selectTriggered on selecting an option(option: MentionOption, trigger: string) => void
openTriggered when opening dropdown() => void
closeTriggered when closing dropdown() => void
keydownTriggered on keydown(event: KeyboardEvent) => void

Slots

SlotDescriptionScope
optionCustom option rendering{ option: MentionOption, keyword: string }
emptyCustom no data content
loadingCustom loading content
prefixCustom prefix content
suffixCustom suffix content

Expose

Prop/MethodDescriptionType
refInput/Textarea DOM elementHTMLInputElement | HTMLTextAreaElement
wrapperRefWrapper DOM elementHTMLElement
focusFocus the input() => void
blurBlur the input() => void
clearClear the input() => void
insertMentionProgrammatically insert mention(option: MentionOption, trigger?: string) => void

Keyboard Operations

KeyDescription
/ Navigate highlight options
EnterSelect highlighted option
TabSelect highlighted option (closes if none)
EscapeClose dropdown panel

Theme Variables

VariableDescriptionDefault
--yh-mention-font-sizeFont sizevar(--yh-font-size-base)
--yh-mention-bg-colorBackground colorvar(--yh-fill-color-blank)
--yh-mention-border-colorBorder colorvar(--yh-border-color)
--yh-mention-border-radiusBorder radiusvar(--yh-border-radius-base)
--yh-mention-height-defaultDefault heightvar(--yh-component-size-default)
--yh-mention-dropdown-shadowDropdown shadowvar(--yh-box-shadow-light)

Released under the MIT License.