PHPackages                             asmit/filament-mention - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. asmit/filament-mention

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

asmit/filament-mention
======================

A Laravel Filament package for implementing a customizable mention editor with support for tagging users or entities.

v1.1.0(1y ago)4416.2k↑20.8%12[5 issues](https://github.com/AsmitNepali/filament-mention/issues)[2 PRs](https://github.com/AsmitNepali/filament-mention/pulls)MITJavaScript

Since Feb 15Pushed 10mo ago1 watchersCompare

[ Source](https://github.com/AsmitNepali/filament-mention)[ Packagist](https://packagist.org/packages/asmit/filament-mention)[ RSS](/packages/asmit-filament-mention/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (6)Dependencies (2)Versions (8)Used By (0)

Filament Mention
================

[](#filament-mention)

The **Mention** plugin allows you to easily mention users in your Filament application using the Filament RichText editor. It supports extracting specific fields from the mentioned user, such as their username, and id. The plugin offers both **static search** (preloaded data) and **dynamic search** (real-time database queries) for mentions.

[![Filament Mention Plugin](https://raw.githubusercontent.com/AsmitNepali/filament-mention/refs/heads/main/images/cover.jpg)](https://raw.githubusercontent.com/AsmitNepali/filament-mention/refs/heads/main/images/cover.jpg)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

[](#)

 [ ![Packagist](https://camo.githubusercontent.com/5d0d888aa2c7547069b0681e23a87e1a092058235403bb1b6af8276eb120560a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f61736d69742f66696c616d656e742d6d656e74696f6e2e7376673f7374796c653d666f722d7468652d6261646765) ](https://packagist.org/packages/asmit/filament-mention) [ ![Packagist](https://camo.githubusercontent.com/d2fbc08e720b3fe7f0b6be7c58c2b5c597650e0721dcaa488ec1e37aae90b840/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f61736d69742f66696c616d656e742d6d656e74696f6e2e7376673f7374796c653d666f722d7468652d6261646765) ](https://packagist.org/packages/asmit/filament-mention/stats) [ ![Packagist](https://camo.githubusercontent.com/47bcf3ffdbf166ce3427dc7f13b5abce903a17397b4b126435673e0b50c77e86/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f61736d69742f66696c616d656e742d6d656e74696f6e2e7376673f7374796c653d666f722d7468652d6261646765) ](#) [ ![Packagist](https://camo.githubusercontent.com/78ddabf6983252d23b39747c4a0e8410019706b5690bc40586161f6a93a2a689/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f61736d69746e6570616c692f66696c616d656e742d6d656e74696f6e3f7374796c653d666f722d7468652d6261646765) ](https://packagist.org/packages/asmitnepali/filament-mention) [ ![Packagist](https://camo.githubusercontent.com/8a486acb259cabf2a9e4feaa18128bd2d1d8226ad52597a74145eeeca13532c2/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f61736d69746e6570616c692f66696c616d656e742d6d656e74696f6e3f7374796c653d666f722d7468652d6261646765) ](https://github.com/AsmitNepali/filament-mention/forks)

---

Features
--------

[](#features)

- **Mention users** in the Filament RichText editor.
- **Extract specific fields** from the mentioned user (e.g. username, id).
- **Static search**: Preload and search from a dataset.
- **Dynamic search**: Fetch data from the database in real-time.
- **Customizable user model and fields**: Use your own `User` model and define which fields to display.
- **Multiple trigger characters**: Use different characters like `@`, `#`, `%` to trigger different types of mentions.
- **Global object search**: Search across all properties of an object without requiring a specific lookup key.
- **Prefix and suffix support**: Add custom text before and after mentions (e.g., `%VARIABLE%`).
- **Customizable title and hint fields**: Configure which fields to use for display in the dropdown menu.
- **Customizable suggestion limits**: Control the number of suggestions displayed and the minimum text length to trigger the search.
- **Avatar and URL support**: Display user avatars and link to their profiles.

Requirements
------------

[](#requirements)

- Filament 3.2 or higher

Installation
------------

[](#installation)

1. Install the package via Composer: ```
    composer require asmit/filament-mention
    ```
2. After installation and update please run the following command to publish the assets: ```
    php artisan filament:assets
    ```
3. Publish the configuration file: ```
    php artisan vendor:publish --provider="Asmit\FilamentMention\FilamentMentionServiceProvider" --tag="asmit-filament-mention-config"
    ```

This will create a `filament-mention.php` file in your `config` directory. You can customize the configuration according to your needs.

---

Upgrading from 1.x to 2.x
-------------------------

[](#upgrading-from-1x-to-2x)

If you are upgrading from version 1.x to 2.x, please note these changes:

1. The configuration key `search_key` is now `search_column`.
2. The `HasMentionable` trait is now `HasMentionableForm`.
3. The `mentionsItems` method is now `mentionableItems`.
4. The form data structure after pluck is change. ```
     [
         'note' => [
             'state' => 'your comment message'
             'mentioned_YOUR-PLUCK-KEY' => [
                 0 => 1,
                 1 => 2,
                 2 => 3,
             ]
     ]```
    ```
5. The `FetchMentionEditor` is deprecated. You can use dynamic search with `getMentionableItemsUsing` method in the `RichMentionEditor` field.

Configuration
-------------

[](#configuration)

The configuration file (`config/filament-mention.php`) allows you to customize the plugin behavior. Here's an example configuration:

```
return [
    'mentionable' => [
        'model' => \App\Models\User::class, // The model to use for mentions
        'column' => [
            'id' => 'id', // Unique identifier for the user
            'display_name' => 'name', // Display name for the mention
            'username' => 'username', // Username for the mention
            'avatar' => 'profile', // Avatar field (e.g. profile picture URL)
        ],
        'url' => 'admin/users/{id}', // this will be used to generate the url for the mention item
        'lookup_key' => 'username', // Used for static search (key in the dataset)
        'search_column' => 'username', // this will be used on dynamic search
    'default' => [
        'trigger_with' => ['@', '#', '%'], // Characters to trigger mentions
        'trigger_configs' => [
            '@' => [
                'prefix' => '',
                'suffix' => '',
                'title_field' => 'name',
                'hint_field' => null,
            ],
            '#' => [
                'prefix' => '',
                'suffix' => '',
                'title_field' => 'name',
                'hint_field' => null,
            ],
            '%' => [
                'prefix' => '%',
                'suffix' => '%',
                'title_field' => 'title',
                'hint_field' => null,
            ],
        ],
        'menu_show_min_length' => 0, // Minimum characters to type before showing suggestions
        'menu_item_limit' => 10, // Maximum number of suggestions to display
        'prefix' => '', // Default prefix for all mentions
        'suffix' => '', // Default suffix for all mentions
        'title_field' => 'title', // Default field to use for title display
        'hint_field' => null, // Default field to use for hint display
    ],
];
```

---

### Key Configuration Options:

[](#key-configuration-options)

- `mentionable.model`: The Eloquent model to use for mentions (e.g. User).
- `mentionable.column`: Map the fields to use for mentions (e.g. id, name, etc.).
- `mentionable.url`: URL pattern for the mention item (e.g. admin/users/{id}).
- `mentionable.lookup_key`: Used for static search (key in the dataset).
- `mentionable.search_column`: Used for dynamic search (database column).
- `default.trigger_with`: Character to trigger mentions (e.g. @).
- `default.menu_show_min_length`: Minimum characters to type before showing suggestions.
- `default.menu_item_limit`: Maximum number of suggestions to display.
- `mentionable.model`: The Eloquent model to use for mentions (e.g. User).
- `mentionable.column`: Map the fields to use for mentions (e.g. id, name, etc.).
- `mentionable.url`: URL pattern for the mention item (e.g. admin/users/{id}).
- `mentionable.lookup_key`: Used for static search (key in the dataset).
- `mentionable.search_key`: Used for dynamic search (database column).
- `default.trigger_with`: Character(s) to trigger mentions (e.g. @, #, %). Can be a string or an array.
- `default.trigger_configs`: Configuration for specific trigger characters.
- `default.menu_show_min_length`: Minimum characters to type before showing suggestions.
- `default.menu_item_limit`: Maximum number of suggestions to display.
- `default.prefix`: Default prefix to add before mentions.
- `default.suffix`: Default suffix to add after mentions.
- `default.title_field`: Default field to use for title display in dropdown.
- `default.hint_field`: Default field to use for hint display in dropdown.

### Recommendations:

[](#recommendations)

- **Use cache to store the mentionable data for static search.**
- **Add indexes to the columns used for dynamic search.**
- **If you are use mention editor inside the modal, please disable grammarly extension by `disableGrammarly()`.**

---

Usage
-----

[](#usage)

### 1. Static Search

[](#1-static-search)

Static search preloads all mentionable data and searches within that dataset. For static search you can you `RichMentionEditor` field.

The `RichMentionEditor` fetch all the mentionable data first and then search the mention item from the fetched data.

```
use Asmit\Mention\Forms\Components\RichMentionEditor;

RichMentionEditor::make('bio')
    ->columnSpanFull(),
```

You can also change the data by pass the closure function `mentionableItems` in the `RichMentionEditor` field.

example:

```
use Asmit\FilamentMention\Forms\Components\RichMentionEditor;
use Asmit\FilamentMention\Dtos\MentionItem;

RichMentionEditor::make('comments')
    ->key(fn () => rand())
    ->disableGrammarly()
    ->lookupKey('username')
    ->mentionableItems(function () {
        return User::all()->map(function ($user) {
            return (new MentionItem(
                id: $user->id,
                username: $user->username,
                displayName: $user->name,
                avatar: $user->profile,
                url: '/users/admin'.$user->id,
            ));
        })->toArray();
    }),
```

#### Key Points

[](#key-points)

- The `mentionableItems` method should return an array of mentionable items.
- The most convenient way to use the `mentionableItems` method is to use the `MentionItem` DTO.
- Use the `lookup_key` to search the mentionable item. You can change the `lookup_key` with chaining the method `lookupKey` in the `RichMentionEditor` field.

> NOTE: If you not use `mentionableItems` then it will use the configuration from config file.

### 2. Dynamic Search

[](#2-dynamic-search)

To enable this feature you need to use the `HasMentionableForm` in to your livewire page.

```
use \Asmit\FilamentMention\Concerns\HasMentionableForm

class FilamentPage {
    use HasMentionableForm;
    // ...
}
```

Next, you can search the mentionable data from the database using the `getMentionableItemsUsing` method in the `RichMentionEditor` field.

```
use Asmit\FilamentMention\Forms\Components\RichMentionEditor;
use Asmit\FilamentMention\Dtos\MentionItem;

RichMentionEditor::make('comments')
    ->key(fn () => rand())
    ->lookupKey('username')
    ->disableGrammarly()
    ->placeholder('Write your comment here...')
    ->getMentionableItemsUsing(function ($query) {
        return User::search($query)
            ->get()
            ->map(function ($user) {
                return new MentionItem(
                    id: $user->id,
                    username: $user->username,
                    displayName: $user->name,
                    avatar: $user->profile,
                    url: '#');
            })->toArray();
    })
```

---

Pluck
-----

[](#pluck)

The plugin allows you to extract specific fields from the mentioned user. You can use the `pluck` method to extract the fields. This feature helps you to customize the mention output according to your needs.

```
use \Asmit\FilamentMention\Forms\Components\RichMentionEditor;

RichMentionEditor::make('note')
    ->pluck('id')
    ->getMentionableItemsUsing(function ($query) {
        return User::search($query)
                ->get()
                ->map(function ($user) {
                    return new MentionItem(
                        id: $user->id,
                        username: $user->username,
                        displayName: $user->name,
                        avatar: $user->profile,
                        url: '#');
                })->toArray();
        })
```

The `pluck` method accepts the `key` to extract the field from the mentioned user. The key should be `id` or `username`. It extracts the data from the MentionItem and return the data in the array format.

It will add the new data attribute named `mentioned_[YOUR PLUCK LEY]`. If you inspect the data it will return like

```
    [
        'note' => [
            'state' => 'your comment message'
            'mentioned_id' => [
                0 => 1,
                1 => 2,
                2 => 3,
            ]
    ]
```

---

Advanced Features
-----------------

[](#advanced-features)

### Multiple Trigger Characters

[](#multiple-trigger-characters)

You can use different characters to trigger different types of mentions. This is useful when you want to mention different types of entities (e.g., users, tags, variables).

```
RichMentionEditor::make('content')
    ->triggerWith(['@', '#', '%'])
```

You can also configure each trigger character separately:

```
RichMentionEditor::make('content')
    ->triggerWith(['@', '#', '%'])
    ->triggerConfigs([
        '@' => [
            'lookupKey' => 'username',
            'prefix' => '',
            'suffix' => '',
            'title_field' => 'name',
            'hint_field' => 'email',
        ],
        '#' => [
            'lookupKey' => 'tag',
            'prefix' => '#',
            'suffix' => '',
            'title_field' => 'name',
            'hint_field' => null,
        ],
        '%' => [
            'lookupKey' => 'name',
            'prefix' => '%',
            'suffix' => '%',
            'title_field' => 'title',
            'hint_field' => null,
        ],
    ])
```

### Global Object Search

[](#global-object-search)

The plugin now supports searching across all properties of an object without requiring a specific lookup key. This makes it easier to find matches regardless of which field contains the search text.

```
RichMentionEditor::make('content')
    ->menuShowMinLength(0) // Show all items immediately
```

### Prefix and Suffix

[](#prefix-and-suffix)

You can add custom text before and after mentions. This is particularly useful for variables or special formatting.

```
RichMentionEditor::make('content')
    ->prefix('%')
    ->suffix('%')
```

You can also configure prefix and suffix for specific trigger characters:

```
RichMentionEditor::make('content')
    ->triggerWith(['@', '%'])
    ->triggerConfigs([
        '@' => [
            'prefix' => '',
            'suffix' => '',
        ],
        '%' => [
            'prefix' => '%',
            'suffix' => '%',
        ],
    ])
```

### Customizable Title and Hint Fields

[](#customizable-title-and-hint-fields)

You can configure which fields to use for the title and hint in the dropdown menu:

```
RichMentionEditor::make('content')
    ->titleField('name')
    ->hintField('email')
```

Or for specific trigger characters:

```
RichMentionEditor::make('content')
    ->triggerWith(['@', '%'])
    ->triggerConfigs([
        '@' => [
            'title_field' => 'name',
            'hint_field' => 'email',
        ],
        '%' => [
            'title_field' => 'title',
            'hint_field' => null,
        ],
    ])
```

### Example: Variables with Prefix and Suffix

[](#example-variables-with-prefix-and-suffix)

Here's an example of using the plugin to insert variables with % prefix and suffix:

```
RichMentionEditor::make('content')
    ->triggerWith('%')
    ->prefix('%')
    ->suffix('%')
    ->menuShowMinLength(0)
    ->mentionsItems([
        [
            'id' => 1,
            'title' => 'SALUTATION',
            'value' => 'salutation',
        ],
        [
            'id' => 2,
            'title' => 'FIRST_NAME',
            'value' => 'firstName',
        ],
        // More variables...
    ])
```

---

Credits
-------

[](#credits)

- [Asmit Nepal](https://github.com/AsmitNepali)
- [Kishan Sunar](https://github.com/Ksunar)
- Jordan Humphreys (Creator of [TributeJs](https://github.com/zurb/tribute))

### Security

[](#security)

If you discover a security vulnerability within this package, please send an e-mail to , All security vulnerabilities will be promptly addressed.

### 🤝 Contributing

[](#-contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### 📄 License

[](#-license)

The MIT License (MIT). Please see [License File](LICENSE.txt) for more information.

*Made with love by Asmit Nepali*

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance50

Moderate activity, may be stable

Popularity40

Moderate usage in the ecosystem

Community14

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 94.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~14 days

Total

6

Last Release

387d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a319ef51eb11470bafa38ab183e1af21162a5d0ed09e48b0595482923816e782?d=identicon)[AsmitNepali](/maintainers/AsmitNepali)

---

Top Contributors

[![AsmitNepali](https://avatars.githubusercontent.com/u/33512152?v=4)](https://github.com/AsmitNepali "AsmitNepali (75 commits)")[![Ksunar](https://avatars.githubusercontent.com/u/161424866?v=4)](https://github.com/Ksunar "Ksunar (3 commits)")[![OccTherapist](https://avatars.githubusercontent.com/u/28587659?v=4)](https://github.com/OccTherapist "OccTherapist (1 commits)")

---

Tags

filamentphplaravelmentionsphp

### Embed Badge

![Health badge](/badges/asmit-filament-mention/health.svg)

```
[![Health](https://phpackages.com/badges/asmit-filament-mention/health.svg)](https://phpackages.com/packages/asmit-filament-mention)
```

###  Alternatives

[codewithdennis/filament-select-tree

The multi-level select field enables you to make single selections from a predefined list of options that are organized into multiple levels or depths.

320392.1k17](/packages/codewithdennis-filament-select-tree)[kirschbaum-development/commentions

A package to allow you to create comments, tag users and more

12369.2k](/packages/kirschbaum-development-commentions)[ralphjsmit/laravel-filament-components

A collection of reusable components for Filament.

10972.2k2](/packages/ralphjsmit-laravel-filament-components)[schmeits/filament-character-counter

This is a Filament character counter TextField and Textarea form field for Filament v4 and v5

33184.7k6](/packages/schmeits-filament-character-counter)[codebar-ag/laravel-filament-json-field

A Laravel Filament JSON Field integration with CodeMirror support

1124.1k](/packages/codebar-ag-laravel-filament-json-field)[asmit/resized-column

Resizeable column for filament

4857.4k1](/packages/asmit-resized-column)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
