Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Filament Context Menu Laravel Package

aymanalhattami/filament-context-menu

Add a right-click context menu to Filament Admin Panel resource pages, custom pages, and table cells. Built from Filament Actions, it supports dark/light modes, RTL/LTR, dividers, and includes refresh, back, and forward actions.

View on GitHub
Deep Wiki
Context7

Getting Started

Pin the package major to your Filament major before installing: v1 for Filament 3, v2 for Filament 4, v3 for Filament 5.

composer require aymanalhattami/filament-context-menu:^3

For a resource or custom page, add PageHasContextMenu and return Filament Actions from getContextMenuActions():

use AymanAlhattami\FilamentContextMenu\Traits\PageHasContextMenu;
use AymanAlhattami\FilamentContextMenu\ContextMenuDivider;
use Filament\Resources\Pages\ListRecords;
use Filament\Actions\Action;

class ListUsers extends ListRecords
{
    use PageHasContextMenu;

    public function getContextMenuActions(): array
    {
        return [
            Action::make('createUser')
                ->label('Create user')
                ->url(CreateUser::getUrl()),

            ContextMenuDivider::make(),

            Action::make('trashedUsers')
                ->label('Trashed users')
                ->url(TrashedUsers::getUrl()),
        ];
    }
}

Look first at the README’s Usage 1 and Usage 2 sections, then the demo project and YouTube video. If examples disagree, inspect the trait and column classes directly.

Your first practical use case should be a ListRecords page where admins repeatedly jump to Create, Trash, Import, or Export. Right-clicking the page background turns those into a shortcut menu without adding more header buttons.

For table-cell menus, replace ordinary table columns with the package’s column wrappers: ContextMenuTextColumn, ContextMenuCheckboxColumn, ContextMenuSelectColumn, ContextMenuColorColumn, ContextMenuIconColumn, ContextMenuImageColumn, ContextMenuTextInputColumn, and ContextMenuToggleColumn.

Implementation Patterns

  • Treat page-level context menus as a power-user shortcut layer, not primary navigation. Keep the important actions visible in page headers or table toolbars too.
  • Reuse Filament’s prebuilt actions where possible: CreateAction, EditAction, ViewAction, DeleteAction, ReplicateAction, ForceDeleteAction, RestoreAction, ImportAction, and ExportAction.
  • On record pages, explicitly bind the record. Prefer $this->getRecord() over hard-coded page properties:
public function getContextMenuActions(): array
{
    return [
        EditAction::make()
            ->record($this->getRecord())
            ->form([
                TextInput::make('name')->required(),
                TextInput::make('email')->email()->required(),
            ]),

        DeleteAction::make()
            ->record($this->getRecord()),
    ];
}
  • Use modal actions for quick edits that do not deserve a full page:
Action::make('quickEditUser')
    ->label('Quick edit user')
    ->form([
        TextInput::make('name'),
        TextInput::make('email'),
    ])
    ->action(function (array $data) {
        $this->getRecord()->update($data);
    });
  • Group related actions with ContextMenuDivider::make(). Keep menus short; 4–8 actions is usually enough before users stop scanning.
  • Use RefreshAction, GoBackAction, and GoForwardAction for cheap navigation UX. They are useful on long admin workflows where users bounce between record pages.
  • For table cells, use the context-menu column wrappers as drop-in replacements and attach row-relevant actions. Keep page-level menus for page-level actions and cell menus for record-level actions.
  • Centralize action arrays in helper methods or dedicated action factories when the same action appears on the page menu, table row action, and toolbar.
  • Control rollout with CONTEXT_MENU_ENABLED globally, public static bool $contextMenuEnabled per page, or isContextMenuEnabled() for dynamic logic.
  • Pair every action with authorization and visibility rules. A right-click menu is still a UI surface and must not expose actions users cannot otherwise perform.

Gotchas and Tips

  • The README is inconsistent about the trait namespace: it mentions AymanAlhattami\FilamentContextMenu\PageHasContextMenu but examples import AymanAlhattami\FilamentContextMenu\Traits\PageHasContextMenu. Verify the actual class in the installed package.
  • The README also alternates between public function getContextMenuActions() and public static function getContextMenuActions(). Use the signature required by your installed version. This matters because closures using $this will fail if the method is static.
  • Version compatibility is the biggest install risk. Pin the package major and test after Filament upgrades; Filament 4 and 5 are not interchangeable with the v1 package line.
  • CONTEXT_MENU_ENABLED is global. If you cache config, run php artisan config:clear after changing it. Do not mix the env flag and page-level flags without testing which one wins in your version.
  • Context menus only appear where the trait or context-menu column wrapper is applied. A normal TextColumn will not gain the menu by configuration alone.
  • Record-bound actions need a record. DeleteAction::make() on a ListRecords page is not the same as on a ViewRecord page; bind ->record() explicitly where needed.
  • Do not rely on the context menu for security. Use ->visible(), policies, and gates. Users can often inspect or trigger action endpoints regardless of whether a button is visible.
  • Right-click is weak on touch devices. If mobile admin use matters, keep equivalent visible buttons and test long-press behavior.
  • Actions inside forms or editable columns can conflict with native browser context menus or inline editing. Test right-click behavior in TextInputColumn and ToggleColumn cells.
  • RefreshAction on an edit page can discard unsaved state. Use it on list/dashboard-style pages, not as a blanket action.
  • Keep action names unique and stable. Prefer names like users.create or quickEditUser rather than display labels as identifiers.
  • The README’s table-cell example is truncated in the provided source. Check the column class API for the exact method used to attach context-menu actions before copying production code.
  • Start with one page and one column. This package is a small UI enhancement with a simple surface area; validate it in context before spreading it across many resources.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
pharaonic/laravel-notification-dependencies
beautinow/translug
dev-brainiac/bot-cloaked
octoberrain/html
octoberrain/extension
octoberrain/exception
octoberrain/contracts
frankyso/ipaymu
3mdikram/worldmoneywords
snowsoft/config
itmosoft/laravel-subscriptions
larva/laravel-ai-qwen
diephp/sequences
users-au/socialite-provider
twidpay/twid-logger
mrnewport/laravel-plaid
mrnewport/laravel-repo
mrnewport/laravel-docsign
mrnewport/laravel-stow
mrnewport/laravel-flow