Introduction
Stats overview widgets provide a clean, organized way to display key metrics and statistics in your Filament application. These widgets are perfect for dashboards, showing important numbers at a glance with optional trend indicators and inline charts. Each stats overview widget can display multiple stat cards in a responsive grid layout, making it easy to showcase various metrics together.Creating a Stats Overview Widget
Generate a stats overview widget using the Artisan command:app/Filament/Widgets/:
Creating Stats
Each stat is created using theStat::make() method with a label and value:
Dynamic Stat Values
Generate stat values from your database:Formatting Numbers
Format large numbers for readability:Adding Descriptions
Provide context with descriptions and trend indicators:Description Icon Position
Place icons before the description:Multiple Descriptions
Show multiple trend indicators:Stat Colors
Apply colors to emphasize stat meaning:primary, success, warning, danger, info, gray.
Dynamic Colors
Set colors based on conditions:Adding Charts to Stats
Display trend charts within stat cards:Generating Chart Data
Use thelaravel-trend package to generate chart data:
Extra HTML Attributes
Add custom attributes for styling or interactions:$ in $dispatch() with \$ since this is passed to HTML, not evaluated as PHP.
Widget Heading and Description
Add a heading and description above the stats:Live Updating (Polling)
Stats widgets refresh every 5 seconds by default:Lazy Loading
Stats widgets are lazy-loaded by default. Disable if needed:Stats Grid Layout
The widget automatically arranges stats in a responsive grid. The grid adapts based on the number of stats:- 1-2 stats: Full width
- 3+ stats: 3 columns on large screens
- Automatically adjusts to 4 columns if the count is optimal
Customizing Grid Columns
Override the$columns property to customize the grid:
Common Stat Patterns
Revenue Statistics
User Growth
Conversion Metrics
Inventory Status
Using Stats with Dashboard Filters
Access dashboard filters to filter stat data:Best Practices
- Keep Numbers Meaningful: Format large numbers (use ‘k’ for thousands, ‘M’ for millions)
- Show Trends: Include descriptions with percentage changes or counts
- Use Appropriate Colors: Green for positive metrics, red for negative, gray for neutral
- Add Context: Descriptions should explain what the number represents
- Include Charts: Small charts help visualize trends at a glance
- Limit Stats Count: 3-6 stats per widget for optimal readability
- Update Regularly: Use polling for real-time data or cache expensive queries
- Consistent Formatting: Use the same number format across related stats
- Icon Consistency: Use trending-up for positive, trending-down for negative
- Responsive Design: Test stats display on different screen sizes
Performance Optimization
For expensive stat calculations, use caching:Next Steps
- Learn about Chart Widgets for detailed data visualization
- Explore Dashboard Filters to filter stats
- Review Widget Polling for real-time updates