---
title: Stats overview widgets
---
import AutoScreenshot from "@components/AutoScreenshot.astro"
## Introduction
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
```
This command will create a new `StatsOverview.php` file. Open it, and return `Stat` instances from the `getStats()` method:
```php
## Adding a description and icon to a stat
You may add a `description()` to provide additional information, along with a `descriptionIcon()`:
```php
use Filament\Widgets\StatsOverviewWidget\Stat;
protected function getStats(): array
{
return [
Stat::make('Unique views', '192.1k')
->description('32k increase')
->descriptionIcon('heroicon-m-arrow-trending-up'),
Stat::make('Bounce rate', '21%')
->description('7% decrease')
->descriptionIcon('heroicon-m-arrow-trending-down'),
Stat::make('Average time on page', '3:12')
->description('3% increase')
->descriptionIcon('heroicon-m-arrow-trending-up'),
];
}
```
The `descriptionIcon()` method also accepts a second parameter to put the icon before the description instead of after it:
```php
use Filament\Support\Enums\IconPosition;
use Filament\Widgets\StatsOverviewWidget\Stat;
Stat::make('Unique views', '192.1k')
->description('32k increase')
->descriptionIcon('heroicon-m-arrow-trending-up', IconPosition::Before)
```
## Changing the color of the stat
You may also give stats a [color](../styling/colors):
```php
use Filament\Widgets\StatsOverviewWidget\Stat;
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
use Filament\Widgets\StatsOverviewWidget\Stat;
protected function getStats(): array
{
return [
Stat::make('Processed', '192.1k')
->color('success')
->extraAttributes([
'class' => 'cursor-pointer',
'wire:click' => "\$dispatch('setStatusFilter', { filter: 'processed' })",
]),
// ...
];
}
```
In this example, we are deliberately escaping the `$` in `$dispatch()` since this needs to be passed directly to the HTML, it is not a PHP variable.
## Setting a placeholder for a stat
Sometimes a stat's value may not be available — for example, when a dashboard has nothing to show for a specific period. You can use `placeholder()` to define what should be displayed instead when the value is blank:
```php
use Filament\Widgets\StatsOverviewWidget\Stat;
Stat::make('Unique views', $uniqueViews)
->placeholder('-')
```
A value is considered blank according to Laravel's `blank()` helper. For example, `null` and empty strings are blank, while `0` and `'0'` are not.
### Setting a default placeholder globally
If you'd like every stat in your app to fall back to the same placeholder by default, you can use the static `configureUsing()` method in a service provider's `boot()` method:
```php
use Filament\Widgets\StatsOverviewWidget\Stat;
Stat::configureUsing(function (Stat $component): void {
$component->placeholder('-');
});
```
Individual stats can still override this by calling `placeholder()` themselves.
## 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
use Filament\Widgets\StatsOverviewWidget\Stat;
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'),
// ...
];
}
```
## Styling stat charts in a theme
Chart.js paints a stat's chart onto a `