@mentionly/vue

Vue 3 mention input component for AI chat scenarios
333 4
Install
npm install @mentionly/vue
Latest Version:2.0.0
Vue:3
License:MIT
Last Updated:Oct 2, 2026
Links: GitHub  ·  npm
Maintainer: jz0ojiang

@mentionly/vue

Vue 3 adapter for mentionly: a lightweight contenteditable mention input for AI chat scenarios, with atomic mention entities, async and paginated data sources, IME handling and serialization.

This package is a thin Vue layer over the framework-agnostic @mentionly/core engine. It exposes:

  • useMention() — headless composable: state as refs, DOM handlers, and the core methods.
  • MentionInput — batteries-included component (editor + dropdown + slots).
  • MentionList — the default dropdown, usable on its own.

Vue 3 is a peer dependency; @mentionly/core is installed automatically.

For AI agents: this package ships llms.txt (node_modules/@mentionly/vue/llms.txt) with setup and integration rules for its installed version. Site-wide docs: llms.txt, llms-full.txt.

Install

npm install @mentionly/vue

If you are upgrading from 1.x, the forwarding package mentionly exposes the same API and ships mentionly/style.css.

Usage

<script setup lang="ts">
import { MentionInput } from '@mentionly/vue'
import type { MentionTrigger, Part } from '@mentionly/vue'
import '@mentionly/vue/style.css'

const triggers: MentionTrigger[] = [
  {
    char: '@',
    items: [
      { id: 'u1', label: 'Alice' },
      { id: 'u2', label: 'Bob' },
    ],
    toData: (item) => ({ kind: 'user', userId: item.id }),
  },
]

function onSubmit(parts: Part[]) {
  // [{ type: 'text', text: 'hi ' },
  //  { type: 'mention', trigger: '@', id: 'u1', label: 'Alice', data: { kind: 'user', userId: 'u1' } }]
}
</script>

<template>
  <MentionInput :triggers="triggers" placeholder="Type a message... try @" @submit="onSubmit" />
</template>

Headless

<script setup lang="ts">
import { useMention } from '@mentionly/vue'

const { editorRef, isOpen, filteredItems, activeIndex, ids, select, handlers, getParts, clear } =
  useMention({
    triggers: [{ char: '@', items: users, toData: (item) => ({ userId: item.id }) }],
  })
</script>

<template>
  <div ref="editorRef" contenteditable v-on="handlers" />
  <ul v-if="isOpen" :id="ids.listbox" role="listbox">
    <li
      v-for="(item, index) in filteredItems"
      :id="ids.option(index)"
      :key="item.id"
      role="option"
      :aria-selected="index === activeIndex"
      @mousedown.prevent="select(item)"
    >
      {{ item.label }}
    </li>
  </ul>
</template>

API

useMention(options)

options is a UseMentionOptions (triggers, insertSpaceAfter, popupMode, popupScrollBehavior). Returns refs (isOpen, filteredItems, activeIndex, query, activeTrigger, loading, error, popupPosition, hasMore, loadingMore, isEmpty), editorRef, ids, handlers, and the methods select, insertMention, loadMore, close, getParts, getDataParts (deprecated), getPlainText, clear, setContent, focus.

MentionInput

Props: triggers, placeholder, disabled, maxHeight, submitOnEnter, onEnter, popupMode, popupScrollBehavior, teleport.

Events: submit(parts: Part[]), change(parts: Part[]).

Slots: #list (with ids), #item, #empty, #error, #loading, #loading-more, #actions, #inner-actions, #default.

Exposed through a template ref: getParts(), getDataParts() (deprecated), getPlainText(), clear(), setContent(parts), insertMention(payload), focus(), ids.

MentionList

Props: items, activeIndex, loading, query, ids (required), hasMore, loadingMore.

Documentation

License

MIT

Related Packages

mentionly

Lightweight Vue 3 mention input component for AI chat scenarios

1,870 4
rt-chat-input

AI聊天输入框组件,支持文本输入、语音录制、文件上传

2,234
@cursortag/mention-kit

Headless zero-dependency TypeScript mention editor for React, Vue 3, and vanilla...

1,783 2
@huyooo/ai-chat-frontend-vue

AI Chat Frontend - Vue components with adapter pattern

12,303
vue-contenteditable-input

Contenteditable directive with v-model, auto focus, preventing new line on enter...

6,798

Version History

Version Released Vue License
2.0.0 ^3.3.0 MIT
Pre-releases (1)
Version Released Vue License
2.0.0-next.0 ^3.3.0 MIT