Tricks

How to override or modify Dashboard page

Oct 18, 2022
Marga Rizaldi
Admin panel, FAQ

The premade dashboard page is mostly enough for general use. But sometimes we might want to change things like icon, heading, navigation label, etc. Let's get it as simple as possible.

  1. Create new Dashboard.php file inside app\Filament\Pages directory:
<?php
 
namespace App\Filament\Pages;
 
use Filament\Pages\Dashboard as BaseDashboard;
 
class Dashboard extends BaseDashboard
{
// Customize properties or methods here
}
  1. Don't forget to unregister the original Dashboard page so that we don't have double dashboard pages. Comment or delete it from the filament.pages.register config inside app\config\filament.php:
'pages' => [
'namespace' => 'App\\Filament\\Pages',
'path' => app_path('Filament/Pages'),
'register' => [
// Pages\Dashboard::class, <-- delete or comment this line.
],
],

That's it. We can now customize our dashboard as we want.

Tips: Check the docs to see everything we can customize.

Example:

<?php
 
namespace App\Filament\Pages;
 
use Filament\Pages\Dashboard as BaseDashboard;
 
class Dashboard extends BaseDashboard
{
protected static ?string $navigationIcon = 'phosphor-gauge-duotone';
 
protected function getHeading(): string
{
$company = auth()->user()->company->name;
return "{$company}'s Dashboard";
}
}

No comments yet…