Menu

Richer stat cards for Filament's stats overview widget
📰

Richer stat cards for Filament's stats overview widget

DEV Community: laravel·Amjad Iqbal·3 days ago
#y8sEzkaH
#devtolaravel#devto#dev#stat#filament
Reading 0:00
15s threshold

Filament's Stat shows a label, a value, a description and a sparkline. Stat Cards is a subclass of it that adds more, without a new widget class or a Livewire component to register.

What it adds

Progress bars, with a custom maximum and an optional label.

Icon tiles, at the start of the label row or the far end of the card.

Colours for the card background, icon, label, value and description.

Trends: pass the current and previous numbers and it writes "12.4% increase" with an arrow, green when the change is good and red when bad.

Badges next to the label.

Bar charts as plain SVG, with no JavaScript.

Install and switch

composer require amjadiqbal/filament-stat-cards

Enter fullscreen mode

Exit fullscreen mode

Then swap one import in your widget:

- use Filament\Widgets\StatsOverviewWidget\Stat; + use AmjadIqbal\FilamentStatCards\Stat;

Enter fullscreen mode

Exit fullscreen mode

Core Stat objects and these ones can sit in the same widget.

Dark mode and limits

Colours come from your panel palette.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.