{"id":36990937,"url":"https://github.com/aymanalhattami/filament-context-menu","last_synced_at":"2026-01-13T23:40:31.792Z","repository":{"id":236454718,"uuid":"788069156","full_name":"aymanalhattami/filament-context-menu","owner":"aymanalhattami","description":"Add a context menu (right click menu) for resource pages, custom pages and table cells of Filament Admin Panel.","archived":false,"fork":false,"pushed_at":"2025-10-13T13:57:50.000Z","size":6466,"stargazers_count":99,"open_issues_count":6,"forks_count":15,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-27T19:32:42.487Z","etag":null,"topics":["filament","javascript","laravel"],"latest_commit_sha":null,"homepage":"https://github.com/aymanalhattami/filament-context-menu","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aymanalhattami.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-04-17T18:05:01.000Z","updated_at":"2025-10-22T02:31:30.000Z","dependencies_parsed_at":"2025-05-12T14:50:32.803Z","dependency_job_id":"10af03b3-efab-4240-bed7-c63dfca9306f","html_url":"https://github.com/aymanalhattami/filament-context-menu","commit_stats":null,"previous_names":["aymanalhattami/filament-context-menu"],"tags_count":5,"template":false,"template_full_name":"filamentphp/plugin-skeleton","purl":"pkg:github/aymanalhattami/filament-context-menu","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aymanalhattami%2Ffilament-context-menu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aymanalhattami%2Ffilament-context-menu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aymanalhattami%2Ffilament-context-menu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aymanalhattami%2Ffilament-context-menu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aymanalhattami","download_url":"https://codeload.github.com/aymanalhattami/filament-context-menu/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aymanalhattami%2Ffilament-context-menu/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28405149,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T21:51:37.118Z","status":"ssl_error","status_checked_at":"2026-01-13T21:45:14.585Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["filament","javascript","laravel"],"created_at":"2026-01-13T23:40:31.287Z","updated_at":"2026-01-13T23:40:31.784Z","avatar_url":"https://github.com/aymanalhattami.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Context Menu for Filament\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/aymanalhattami/filament-context-menu.svg?style=flat-square)](https://packagist.org/packages/aymanalhattami/filament-context-menu)\n[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/aymanalhattami/filament-context-menu/run-tests.yml?branch=main\u0026label=tests\u0026style=flat-square)](https://github.com/aymanalhattami/filament-context-menu/actions?query=workflow%3Arun-tests+branch%3Amain)\n[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/aymanalhattami/filament-context-menu/fix-php-code-style-issues.yml?branch=main\u0026label=code%20style\u0026style=flat-square)](https://github.com/aymanalhattami/filament-context-menu/actions?query=workflow%3A\"Fix+PHP+code+styling\"+branch%3Amain)\n[![Total Downloads](https://img.shields.io/packagist/dt/aymanalhattami/filament-context-menu.svg?style=flat-square)](https://packagist.org/packages/aymanalhattami/filament-context-menu)\n\n---\nAdd a context menu (right click menu) for resource pages, custom pages and table cells of [Filament Admin Panel](https://filamentphp.com/).\n* It uses [Filament Actions](https://filamentphp.com/docs/3.x/actions/overview) to set menu actions.\n* It supports dark and light modes.\n* It supports left-to-right and right-to-left direction.\n* You can set a divider between menu actions.\n* It supports resource pages and custom pages.\n* You can set a context menu for table cells.\n* Three actions are available for usage in the page context menu:\n    * ```AymanAlhattami\\FilamentContextMenu\\Actions\\RefreshAction``` to refresh the page.\n    * ```AymanAlhattami\\FilamentContextMenu\\Actions\\GoBackAction``` to go back to the previous page.\n    * ```AymanAlhattami\\FilamentContextMenu\\Actions\\GoForward``` to go back to the forward page.\n\n[Demo project](https://github.com/aymanalhattami/filament-context-menu-project) | [Youtube video](https://www.youtube.com/watch?v=ciTH-u5sluw) | [Laravel Daily (Povilas Korop) Video](https://www.youtube.com/watch?v=ZqJ96GCtfBQ)\n\n## Installation\n\nYou can install the package via Composer:\n\n```bash\ncomposer require aymanalhattami/filament-context-menu\n```\n\n## Usage 1: resource pages and custom pages\n1. Add the trait ```AymanAlhattami\\FilamentContextMenu\\PageHasContextMenu``` to the page you want to add the context menu.\n2. Then, define a ```getContextMenuActions``` method inside the page, the method should return an array of [Filament Actions](https://filamentphp.com/docs/3.x/actions/installation)\n\n```php\nuse App\\Filament\\Resources\\UserResource\\Pages\\CreateUser;\nuse AymanAlhattami\\FilamentContextMenu\\Traits\\PageHasContextMenu;\nuse Filament\\Actions\\Action;\nuse Filament\\Resources\\Pages\\ListRecords;\n\nclass ListUsers extends ListRecords\n{\n    use PageHasContextMenu;\n    \n    public function getContextMenuActions(): array\n    {\n        return [\n            Action::make('Create user')\n                -\u003eurl(CreateUser::getUrl())\n        ];\n    }\n    \n    // \n}\n```\n\n### Divider\nYou can use ```AymanAlhattami\\FilamentContextMenu\\ContextMenuDivider``` to set divider between menu actions\n\n```php\nuse App\\Filament\\Resources\\UserResource\\Pages\\CreateUser;\nuse App\\Filament\\Resources\\UserResource\\Pages\\TrashedUsers;\nuse AymanAlhattami\\FilamentContextMenu\\ContextMenuDivider;\nuse AymanAlhattami\\FilamentContextMenu\\Traits\\PageHasContextMenu;\nuse Filament\\Actions\\Action;\nuse Filament\\Resources\\Pages\\ListRecords;\n\nclass ListUsers extends ListRecords\n{\n    use PageHasContextMenu;\n\n    // \n    \n    public static function getContextMenuActions(): array\n    {\n        return [\n            Action::make('Create user')\n                -\u003eurl(CreateUser::getUrl()),\n            ContextMenuDivider::make(),\n            Action::make('Trashed user')\n                -\u003eurl(TrashedUsers::getUrl()),\n        ];\n    }\n    \n    // \n}\n```\n\n### Create Action\nYou can use ```Filament\\Actions\\CreateAction```, visit [filament create action](https://filamentphp.com/docs/3.x/actions/prebuilt-actions/create) for more information.\n\n```php\nuse AymanAlhattami\\FilamentContextMenu\\Traits\\PageHasContextMenu;\nuse Filament\\Resources\\Pages\\ListRecords;\n\nclass ListUsers extends ListRecords\n{\n    use PageHasContextMenu;\n\n    // \n    \n    public static function getContextMenuActions(): array\n    {\n        return [\n            \\Filament\\Actions\\CreateAction::make()\n                -\u003emodel(App\\Models\\User::class)\n                 -\u003eform([\n                    TextInput::make('name')\n                        -\u003erequired(),\n                    // ...\n                ])\n        ];\n    }\n    \n    // \n}\n```\n\n### Edit Action\nYou can use ```Filament\\Actions\\EditAction```, visit [filament edit action](https://filamentphp.com/docs/3.x/actions/prebuilt-actions/edit) for more information.\n\n```php\nuse AymanAlhattami\\FilamentContextMenu\\Traits\\PageHasContextMenu;\nuse Filament\\Resources\\Pages\\ViewRecord;\n\nclass ViewUser extends ViewRecord\n{\n    use PageHasContextMenu;\n\n    // \n    \n    public static function getContextMenuActions(): array\n    {\n        return [\n            \\Filament\\Actions\\EditAction::make()\n                -\u003erecord($this-\u003euser)\n                -\u003eform([\n                    TextInput::make('name')\n                        -\u003erequired(),\n                    // ...\n                ])\n        ];\n    }\n    \n    // \n}\n```\n\n### View Action\nYou can use ```Filament\\Actions\\ViewAction```, visit [filament view action](https://filamentphp.com/docs/3.x/actions/prebuilt-actions/view) for more information.\n\n```php\nuse AymanAlhattami\\FilamentContextMenu\\Traits\\PageHasContextMenu;\nuse Filament\\Resources\\Pages\\EditRecord;\n\nclass EditUser extends EditRecord\n{\n    use PageHasContextMenu;\n\n    // \n    \n    public static function getContextMenuActions(): array\n    {\n        return [\n            \\Filament\\Actions\\ViewAction::make()\n                -\u003erecord($this-\u003euser)\n                 -\u003eform([\n                    TextInput::make('name')\n                        -\u003erequired(),\n                    // ...\n                ])\n                \n        ];\n    }\n    \n    // \n}\n```\n\n### Delete Action\nYou can use  ```Filament\\Actions\\DeleteAction```, visit [filament delete action](https://filamentphp.com/docs/3.x/actions/prebuilt-actions/delete) for more information.\n\n```php\nuse AymanAlhattami\\FilamentContextMenu\\Traits\\PageHasContextMenu;\nuse Filament\\Resources\\Pages\\ViewRecord;\n\nclass ViewUser extends ViewRecord\n{\n    use PageHasContextMenu;\n\n    // \n    \n    public static function getContextMenuActions(): array\n    {\n        return [\n            \\Filament\\Actions\\DeleteAction::make()\n                -\u003erecord($this-\u003euser)\n        ];\n    }\n    \n    // \n}\n```\n\n### Replicate Action\nYou can use  ```Filament\\Actions\\ReplicateAction```, visit [filament replicate action](https://filamentphp.com/docs/3.x/actions/prebuilt-actions/replicate) for more information.\n\n```php\nuse AymanAlhattami\\FilamentContextMenu\\Traits\\PageHasContextMenu;\nuse Filament\\Resources\\Pages\\ViewRecord;\n\nclass ViewUser extends ViewRecord\n{\n    use PageHasContextMenu;\n\n    // \n    \n    public static function getContextMenuActions(): array\n    {\n        return [\n            \\Filament\\Actions\\ReplicateAction::make()\n                -\u003erecord($this-\u003euser)\n        ];\n    }\n    \n    // \n}\n```\n\n### Force Delete Action\nYou can use ```Filament\\Actions\\ForceDeleteAction```, visit [filament force delete action](https://filamentphp.com/docs/3.x/actions/prebuilt-actions/force-delete) for more information.\n\n```php\nuse AymanAlhattami\\FilamentContextMenu\\Traits\\PageHasContextMenu;\nuse Filament\\Resources\\Pages\\ViewRecord;\n\nclass ViewUser extends ViewRecord\n{\n    use PageHasContextMenu;\n\n    // \n    \n    public static function getContextMenuActions(): array\n    {\n        return [\n            \\Filament\\Actions\\ForceDeleteAction::make()\n                -\u003erecord($this-\u003euser)\n        ];\n    }\n    \n    // \n}\n```\n\n### Restore Action\nYou can use ```Filament\\Actions\\RestoreAction```, visit [filament restore action](https://filamentphp.com/docs/3.x/actions/prebuilt-actions/restore) for more information.\n\n```php\nuse AymanAlhattami\\FilamentContextMenu\\Traits\\PageHasContextMenu;\nuse Filament\\Resources\\Pages\\ListRecords;\n\nclass ListUsers extends ListRecords\n{\n    use PageHasContextMenu;\n\n    // \n    \n    public static function getContextMenuActions(): array\n    {\n        return [\n            \\Filament\\Actions\\RestoreAction::make()\n                -\u003erecord($this-\u003euser)\n        ];\n    }\n    \n    // \n}\n```\n\n### Import Action\nYou can use ```Filament\\Actions\\ImportAction```, visit [filament import action](https://filamentphp.com/docs/3.x/actions/prebuilt-actions/import) for more information.\n\n```php\nuse App\\Filament\\Imports\\UserImporter;\nuse AymanAlhattami\\FilamentContextMenu\\Traits\\PageHasContextMenu;\nuse Filament\\Resources\\Pages\\ListRecords;\n\nclass ListUsers extends ListRecords\n{\n    use PageHasContextMenu;\n\n    // \n    \n    public static function getContextMenuActions(): array\n    {\n        return [\n            \\Filament\\Actions\\ImportAction::make()\n                -\u003eimporter(UserImporter::class)\n        ];\n    }\n    \n    // \n}\n```\n\n### Export Action\nYou can use ```Filament\\Actions\\ExportAction```, visit [filament export action](https://filamentphp.com/docs/3.x/actions/prebuilt-actions/export) for more information.\n\n```php\nuse App\\Filament\\Exports\\UserExporter;\nuse AymanAlhattami\\FilamentContextMenu\\Traits\\PageHasContextMenu;\nuse Filament\\Resources\\Pages\\ListRecords;\n\nclass ListUsers extends ListRecords\n{\n    use PageHasContextMenu;\n\n    // \n    \n    public static function getContextMenuActions(): array\n    {\n        return [\n            \\Filament\\Actions\\ExportAction::make()\n                -\u003eexporter(UserExporter::class)\n        ];\n    }\n    \n    // \n}\n```\n\n### Example: action with modal\nYou can use filament action with modal\n\n```php\nuse AymanAlhattami\\FilamentContextMenu\\Traits\\PageHasContextMenu;\nuse Filament\\Resources\\Pages\\ViewRecord;\nuse Filament\\Actions\\Action;\n\nclass ViewUser extends ViewRecord\n{\n    use PageHasContextMenu;\n\n    // \n    \n    public static function getContextMenuActions(): array\n    {\n        return [\n            Action::make('Quick edit user')\n                -\u003eform([\n                    \\Filament\\Forms\\Components\\Grid::make(2)\n                        -\u003eschema([\n                            TextInput::make('name'),\n                            TextInput::make('email'),\n                        ])\n                ])\n                -\u003eaction(function($data){\n                    $this-\u003egetRecord()-\u003eupdate([\n                        'name' =\u003e $data['name'],\n                        'email' =\u003e $data['email'],\n                    ]);\n                })\n        ];\n    }\n    \n    // \n}\n```\n\n### Example: refresh, go back and go forward actions\n\n```php\nuse AymanAlhattami\\FilamentContextMenu\\Traits\\PageHasContextMenu;\nuse Filament\\Resources\\Pages\\ViewRecord;\nuse AymanAlhattami\\FilamentContextMenu\\Actions\\{ RefreshAction, GoBackAction, GoForwardAction}; \n\nclass ViewUser extends ViewRecord\n{\n    use PageHasContextMenu;\n\n    // \n    \n    public static function getContextMenuActions(): array\n    {\n        return [\n            RefreshAction::make(),\n            GoBackAction::make(),\n            GoForwardAction::make()\n        ];\n    }\n    \n    // \n}\n```\n\n### Enable / Disable context menu in resource pages and custom pages\nMethod 1: To globally enable or disable the context menu, you need to define an env variable called ```CONTEXT_MENU_ENABLED```  and to set the value to ```true``` or ```false```.\n\nMethod 2: You can also define a static variable called ```public static bool $contextMenuEnabled``` in the page and set the value to ```true``` or ```false```;\n\n```php\nuse AymanAlhattami\\FilamentContextMenu\\Traits\\PageHasContextMenu;use Filament\\Resources\\Pages\\ViewRecord;\n\nclass ViewUser extends ViewRecord\n{\n    use PageHasContextMenu;\n    \n    # enable / disable context menu\n    public static bool $contextMenuEnabled = true;\n\n    // \n    \n    public static function getContextMenuActions(): array\n    {\n        return [];\n    }\n    \n    // \n}\n```\n\nMethod 3: define a static method called ```isContextMenuEnabled``` in the page\n\n```php\nuse AymanAlhattami\\FilamentContextMenu\\Traits\\PageHasContextMenu;use Filament\\Resources\\Pages\\ViewRecord;\n\nclass ViewUser extends ViewRecord\n{\n    use PageHasContextMenu;\n    \n    public static function isContextMenuEnabled(): bool\n    {\n        return true;\n    }\n\n    // \n    \n    public static function getContextMenuActions(): array\n    {\n        return [];\n    }\n    \n    // \n}\n```\n\n## Usage 2: table cells\nTo add a context menu to the table cell, you can use the following columns: \n```php \n AymanAlhattami\\FilamentContextMenu\\Columns\\ContextMenuTextColumn;\n AymanAlhattami\\FilamentContextMenu\\Columns\\ContextMenuCheckboxColumn;\n AymanAlhattami\\FilamentContextMenu\\Columns\\ContextMenuSelectColumn;\n AymanAlhattami\\FilamentContextMenu\\Columns\\ContextMenuColorColumn;\n AymanAlhattami\\FilamentContextMenu\\Columns\\ContextMenuIconColumn;\n AymanAlhattami\\FilamentContextMenu\\Columns\\ContextMenuImageColumn; \n AymanAlhattami\\FilamentContextMenu\\Columns\\ContextMenuTextInputColumn;\n AymanAlhattami\\FilamentContextMenu\\Columns\\ContextMenuToggleColumn;\n```\n\n```php\nuse Filament\\Tables\\Table;\nuse Filament\\Tables\\Actions\\Action;\nuse AymanAlhattami\\FilamentContextMenu\\Columns\\ContextMenuTextColumn;\nuse App\\Filament\\Resources\\UserResource\\Pages\\{ ViewUser, EditUser };\n\n//\npublic static function table(Table $table): Table\n    {\n        return $table\n            -\u003ecolumns([\n                ContextMenuTextColumn::make('id')\n                    -\u003esearchable()\n                    -\u003econtextMenuActions(fn (Model $record) =\u003e [\n                        Action::make('View user')\n                            -\u003eurl(ViewUser::getUrl(['record' =\u003e $record]))\n                            -\u003elink()\n                            -\u003eicon('heroicon-o-user'),\n                    ]),\n                ContextMenuTextColumn::make('name')\n                    -\u003esearchable()\n                    -\u003econtextMenuActions(fn (Model $record) =\u003e [\n                        Action::make('View user')\n                            -\u003eurl(Pages\\ViewUser::getUrl(['record' =\u003e $record]))\n                            -\u003elink()\n                            -\u003eicon('heroicon-o-user'),\n                        Action::make('Edit user')\n                            -\u003eurl(Pages\\EditUser::getUrl(['record' =\u003e $record]))\n                            -\u003elink()\n                            -\u003eicon('heroicon-o-pencil'),\n                    ])\n                    ,\n                ,\n            ])\n}\n```\nUse ```AymanAlhattami\\FilamentContextMenu\\ContextMenuDivider``` to set a divider between menu actions.\n\n### enable / disable table cell context menu\nUse ```-\u003econtextMenuEnabled()``` method to enable/disable the context menu for the table cell.\n\n```php\n//\npublic static function table(Table $table): Table\n    {\n        return $table\n            -\u003ecolumns([\n                ContextMenuTextColumn::make('id')\n                    -\u003econtextMenuEnabled(false)\n                    -\u003econtextMenuActions(fn (Model $record) =\u003e [\n                        Action::make('View user')\n                            -\u003eurl(ViewUser::getUrl(['record' =\u003e $record]))\n                            -\u003elink()\n                            -\u003eicon('heroicon-o-user'),\n                    ]),\n//\n```\n\n## Note \nFor action to have a nice style, use ```-\u003elink()``` method of the action, [more information](https://filamentphp.com/docs/3.x/actions/trigger-button#choosing-a-trigger-style)\n \n```php\npublic static function getContextMenuActions(): array\n{\n    return [\n        Action::make('Create user')\n            -\u003eurl(CreateUser::getUrl())\n            -\u003elink()\n        ];\n}\n```\n\n## Testing\n\n```bash\ncomposer test\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.\n\n## Security Vulnerabilities\n\n\nPlease review [our security policy](../../security/policy) on how to report security vulnerabilities.\n\n## Credits\n\n- [aymanalhattami](https://github.com/aymanalhattami)\n\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faymanalhattami%2Ffilament-context-menu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faymanalhattami%2Ffilament-context-menu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faymanalhattami%2Ffilament-context-menu/lists"}