Skip to content

Commit

Permalink
Merge pull request #12862 from xikcode/patch-1
Browse files Browse the repository at this point in the history
Improve Stats Overview Widgets documentation
  • Loading branch information
danharrin authored May 20, 2024
2 parents 03b8b60 + 9a583fd commit 7db11d8
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions packages/widgets/docs/02-stats-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ Now, check out your widget in the dashboard.
You may add a `description()` to provide additional information, along with a `descriptionIcon()`:

```php
use Filament\Widgets\StatsOverviewWidget\Stat;

protected function getStats(): array
{
return [
Expand All @@ -58,11 +60,24 @@ protected function getStats(): array
}
```

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()` (`danger`, `gray`, `info`, `primary`, `success` or `warning`):

```php
use Filament\Widgets\StatsOverviewWidget\Stat;

protected function getStats(): array
{
return [
Expand All @@ -87,6 +102,8 @@ protected function getStats(): array
You may also pass extra HTML attributes to stats using `extraAttributes()`:

```php
use Filament\Widgets\StatsOverviewWidget\Stat;

protected function getStats(): array
{
return [
Expand All @@ -108,6 +125,8 @@ In this example, we are deliberately escaping the `$` in `$dispatch()` since thi
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 [
Expand Down

0 comments on commit 7db11d8

Please sign in to comment.