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.
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.
CreateAction, EditAction, ViewAction, DeleteAction, ReplicateAction, ForceDeleteAction, RestoreAction, ImportAction, and ExportAction.$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()),
];
}
Action::make('quickEditUser')
->label('Quick edit user')
->form([
TextInput::make('name'),
TextInput::make('email'),
])
->action(function (array $data) {
$this->getRecord()->update($data);
});
ContextMenuDivider::make(). Keep menus short; 4–8 actions is usually enough before users stop scanning.RefreshAction, GoBackAction, and GoForwardAction for cheap navigation UX. They are useful on long admin workflows where users bounce between record pages.CONTEXT_MENU_ENABLED globally, public static bool $contextMenuEnabled per page, or isContextMenuEnabled() for dynamic logic.AymanAlhattami\FilamentContextMenu\PageHasContextMenu but examples import AymanAlhattami\FilamentContextMenu\Traits\PageHasContextMenu. Verify the actual class in the installed package.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.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.TextColumn will not gain the menu by configuration alone.DeleteAction::make() on a ListRecords page is not the same as on a ViewRecord page; bind ->record() explicitly where needed.->visible(), policies, and gates. Users can often inspect or trigger action endpoints regardless of whether a button is visible.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.users.create or quickEditUser rather than display labels as identifiers.How can I help you explore Laravel packages today?