--- title: "@Mentions in the Vue 3 Editor" description: "Set up @mention suggestions in Vue 3 with static or async items in :init, listen for mention-select and mention-remove, and restyle rows with named slots." head: - - meta - name: robots content: 'index, follow, max-image-preview:large, max-snippet:-1, max-video-preview:-1' - - meta - name: googlebot content: 'index, follow, max-image-preview:large, max-snippet:-1, max-video-preview:-1' - - meta - name: bingbot content: 'index, follow, max-image-preview:large, max-snippet:-1, max-video-preview:-1' ---
# @Mentions in the Vue 3 Editor In Vue 3, mentions are configured on the `mentions` key of the object bound to `:init`. Typing `@` opens a suggestion list fed by an array or an async function, picks are reported through the `mention-search`, `mention-select`, and `mention-remove` events, and named slots such as `#mention-item` let you change how each row and state looks. As users type, a debounced autocomplete dropdown appears at the cursor location. Selecting a user inserts a non-editable chip element complete with an accessible hover user card. Mentions are disabled by default. Enable them with `mentions: true` or with an object whose `enabled` value is `true`. The trigger is always `@` and is not configurable. If you need placeholders that the server replaces later, use [merge tags](./merge-tags.html) instead. --- ## Key HighlightsIn the Vue editor, @ is the fixed trigger. Typing it opens a suggestion list next to the cursor.
Set items to an async function. Searches are debounced (200ms by default) and every call receives an AbortSignal for dropping stale requests.
The same query is not fetched twice in one editor session; earlier results are served from a local cache.
Move with the Up / Down arrows, insert with Enter or Tab, and dismiss the list with Esc.
` blocks, existing mentions, non-editable elements, email addresses, URL paths, disabled editors, or readonly editors. Whitespace closes the query.
## Dropdown states and controls
The caret-positioned dropdown supports loading, empty, error, and results states. Failed async requests show a Retry action. The first result is active automatically, and the dropdown flips above the caret when there is not enough viewport space below it.
| Key | Behavior |
| ----------- | ---------------------------------------------- |
| `ArrowDown` | Select the next result, wrapping at the end. |
| `ArrowUp` | Select the previous result, wrapping at start. |
| `Home` | Select the first result. |
| `End` | Select the last result. |
| `Enter` | Insert the active result. |
| `Tab` | Insert the active result without moving focus. |
| `Escape` | Close without inserting. |
Hovering a result updates the active option. Clicking uses pointer handling that preserves the editor selection, so the mention is inserted once at the original query range.
The default result UI is intentionally compact: each row has a `50px` minimum height, `6px 10px` padding, an `8px` content gap, and a `38px` avatar. The description uses only a `1px` top margin. Override `.erag-mention-dropdown__item`, `.erag-mention-dropdown__avatar`, and `.erag-mention-dropdown__description` after the package stylesheet when a denser or roomier application style is required.
## Hover card
Hover an inserted mention to display its known avatar, label, description, and value. If the avatar is missing or cannot load, the card shows initials. The card remains inside the viewport and uses the item data cached during the current editor session.
---
## Mention Lifecycle Events
Track mention search, insertion, and deletion events in your application:
```vue
```
- **`mention-search`**: Fired with `{ query }` when debounced search starts.
- **`mention-select`**: Fired with `{ item, query }` when a user selects a mention option.
- **`mention-remove`**: Fired with `{ item }` when `Backspace` or `Delete` removes an inserted mention chip.
---
## Mention slots
The editor supplies a complete default UI, but these slots can customize dropdown content without replacing its keyboard handling:
```vue
{{ active ? '→' : '' }} {{ item.label }}
Loading {{ query }}…
No result for {{ query }}
```
---
## HTML Output Format
Inserted mentions render as non-editable inline chips:
```html
@Damon Cross
```
When `value` is absent, `data-erag-mention-value` is omitted. Your server sanitizer should allow these attributes; the list is on the [security and sanitization](./security.html) page. Pressing Backspace immediately after a mention or Delete immediately before it removes the complete chip and keeps the removal undoable.