kenepa / multi-widget
A Filament widget that encompasses multiple widgets.
Installs: 37 507
Dependents: 1
Suggesters: 0
Security: 0
Stars: 43
Watchers: 2
Forks: 10
Open Issues: 4
Requires
- php: ^8.0
- filament/filament: ^3.0
- spatie/laravel-package-tools: ^1.15.0
Requires (Dev)
- tightenco/duster: ^2.0
This package is auto-updated.
Last update: 2024-12-17 11:47:06 UTC
README
Filament Multi Widget adds a new type of widget to your Filament application. The Multi Widget allows you to combine multiple widgets into a single widget, that can be switched using tabs. This plugin helps clean up your Filament dashboard.
Installation
You can install the package via composer:
composer require kenepa/multi-widget
Usage
Create a new Multi Widget by extending the Kenepa\MultiWidget\MultiWidget
class.
// app/Filament/Widgets/UserMultiWidget.php class UserMultiWidget extends MultiWidget { public array $widgets = [ MySubmittedComments::class, MySubmittedFeedback::class, MySubscriptions::class, ]; }
The $widgets
property contains the classes of all the widgets that should be added to your Multi Widget. These are normal Filament widgets that you created.
The Multi Widget above will now render as follows:
In case your widget is displayed a second time on the dashboard, make sure the widget is not automatically added to the dashboard again. Check the discoverWidgets()
function in your adminPanelProvider.php
file.
Using custom labels for tabs
By default, the label name is generated based on the class name. If you want to customize the label for the tab, add the getDisplayName()
method to your widget.
// app/Filament/Widgets/ProductSales.php class ProductSales extends BaseWidget { // Some widget content... public function getDisplayName(): string { return "Custom name"; } }
Persist tabs in session
To persist the tabs in the user's session, use the shouldPersistMultiWidgetTabsInSession() method:
// app/Filament/Widgets/UserMultiWidget.php class UserMultiWidget extends MultiWidget { public array $widgets = [ MySubmittedComments::class, MySubmittedFeedback::class, MySubscriptions::class, ]; public function shouldPersistMultiWidgetTabsInSession(): bool { return true; } }
License
The MIT License (MIT). Please see License File for more information.