--- title: Stats overview widgets --- ## Overview Filament comes with a "stats overview" widget template, which you can use to display a number of different stats in a single widget, without needing to write a custom view. Start by creating a widget with the command: ```bash php artisan make:filament-widget StatsOverview --stats-overview ``` Then return `Stat` instances from the `getStats()` method: ```php description('32k increase') ->descriptionIcon('heroicon-m-arrow-trending-up'), Stat::make('Bounce rate', '21%') ->description('7% increase') ->descriptionIcon('heroicon-m-arrow-trending-down'), Stat::make('Average time on page', '3:12') ->description('3% increase') ->descriptionIcon('heroicon-m-arrow-trending-up'), ]; } ``` ## Changing the color of the stat You may also give stats a `color()` (`danger`, `gray`, `info`, `primary`, `success` or `warning`): ```php protected function getStats(): array { return [ Stat::make('Unique views', '192.1k') ->description('32k increase') ->descriptionIcon('heroicon-m-arrow-trending-up') ->color('success'), Stat::make('Bounce rate', '21%') ->description('7% increase') ->descriptionIcon('heroicon-m-arrow-trending-down') ->color('danger'), Stat::make('Average time on page', '3:12') ->description('3% increase') ->descriptionIcon('heroicon-m-arrow-trending-up') ->color('success'), ]; } ``` ## Adding extra HTML attributes to a stat You may also pass extra HTML attributes to stats using `extraAttributes()`: ```php protected function getStats(): array { return [ Stat::make('Processed', '192.1k') ->color('success') ->extraAttributes([ 'class' => 'cursor-pointer', 'wire:click' => '$dispatch("setStatusFilter", "processed")', ]), // ... ]; } ``` ## Adding a chart to a stat You may also add or chain a `chart()` to each stat to provide historical data. The `chart()` method accepts an array of data points to plot: ```php protected function getStats(): array { return [ Stat::make('Unique views', '192.1k') ->description('32k increase') ->descriptionIcon('heroicon-m-arrow-trending-up') ->chart([7, 2, 10, 3, 15, 4, 17]) ->color('success'), // ... ]; } ``` ## Live updating stats (polling) By default, stats overview widgets refresh their data every 5 seconds. To customize this, you may override the `$pollingInterval` property on the class to a new interval: ```php protected static ?string $pollingInterval = '10s'; ``` Alternatively, you may disable polling altogether: ```php protected static ?string $pollingInterval = null; ``` ## Disabling lazy loading By default, widgets are lazy-loaded. This means that they will only be loaded when they are visible on the page. To disable this behavior, you may override the `$isLazy` property on the widget class: ```php protected static bool $isLazy = true; ```