Introduction
Filament allows you to build dynamic dashboards comprised of “widgets”. Each widget is a component that displays data in a specific way, helping you create rich, interactive admin panels and information displays. Widgets are Livewire components that can display stats, charts, tables, or any custom content you need. They’re commonly used on dashboard pages, but can also be integrated into resource pages and custom layouts.Widget Types
Filament provides several built-in widget types:- Stats Overview Widgets: Display key metrics and statistics with optional charts
- Chart Widgets: Render interactive charts using Chart.js
- Table Widgets: Display data in tabular format
- Custom Widgets: Build completely custom widgets with your own views
Creating a Widget
Use themake:filament-widget Artisan command to create a widget:
- Custom - A blank widget you can customize
- Chart - A chart widget
- Stats overview - A stats overview widget
- Table - A table widget
app/Filament/Widgets/ and registers it automatically if you’re using widget discovery.
Dashboard Widgets
By default, widgets are displayed on the main dashboard page. Filament automatically discovers widgets in theapp/Filament/Widgets directory.
Widget Discovery
To enable automatic widget discovery, configure it in your panel provider:Manual Widget Registration
You can also manually register widgets:Disabling Default Widgets
Filament includes two default widgets on the dashboard. To disable them:Ordering Widgets
Control the order in which widgets appear using the$sort property:
Widget Width and Layout
Control how much space a widget occupies using the$columnSpan property:
Responsive Widget Widths
Make widget widths responsive using an array:Customizing the Widgets Grid
By default, widgets are displayed in a 2-column grid. To customize this, you need to create a custom dashboard page.Creating a Custom Dashboard
Create a new dashboard page:Responsive Widget Grids
Make the grid responsive:Multiple Dashboards
Create multiple dashboard pages for different purposes:Conditionally Hiding Widgets
Hide widgets based on user permissions or other conditions:Widget Polling
Many widgets support live polling to automatically refresh data:Lazy Loading
By default, widgets are lazy-loaded (only rendered when visible):Filtering Widget Data
You can add filters to your dashboard that affect all widgets.Using a Filter Form
Add filters using theHasFiltersForm trait:
Using a Filter Action
For a cleaner UI, use a filter action modal:Accessing Filters in Widgets
Use theInteractsWithPageFilters trait to access filter data:
Persisting Filters
By default, filters persist in the user’s session. To disable:Table Widgets
Table widgets display data in tabular format using Filament’s table builder:Custom Widgets
Create completely custom widgets for unique requirements:Using Widgets Outside Dashboards
Widgets can be used on resource pages and custom pages:Widget Headings and Descriptions
Add headings and descriptions to widgets:Best Practices
- Keep Widgets Focused: Each widget should display one type of information clearly
- Use Appropriate Types: Choose stats for metrics, charts for trends, tables for detailed data
- Consider Performance: Use caching for expensive queries, especially with polling enabled
- Responsive Design: Test widgets on different screen sizes using responsive column spans
- Lazy Loading: Keep lazy loading enabled for widgets below the fold
- Filter Consistency: When using dashboard filters, ensure all widgets handle them appropriately
- Sort Logically: Place most important widgets at the top using the
$sortproperty
Next Steps
- Learn about Chart Widgets to visualize data
- Explore Stats Overview Widgets to display key metrics
- Understand Tables for detailed data display