Hero background

Data Widgets

Transform raw information into engaging visual narratives that tell the story of your application's data. Filament's data widgets go beyond simple statistics to create interactive dashboards that highlight trends, showcase activity, and present actionable insights. Whether you're building activity feeds that capture user engagement, summary cards that spotlight key performance indicators, or alert widgets that demand immediate attention, these components ensure your most important data never gets lost in the noise.

# Quick Stats Tables

Quick Stats Tables

Create compact data presentations that surface the most important metrics without overwhelming users. These widgets excel at showing top performers, recent entries, or filtered subsets of data with clean typography and smart responsive behavior that maintains readability across devices.

<?php

namespace App\Filament\Widgets;

use App\Models\Customer;
use Filament\Actions\Action;
use Filament\Tables;
use Filament\Tables\Table;
use Filament\Widgets\TableWidget as BaseWidget;

class TopCustomersWidget extends BaseWidget
{
    protected static ?string $heading = 'Top Customers This Month';
    protected int | string | array $columnSpan = 2;
    protected static ?int $sort = 2;

    public function table(Table $table): Table
    {
        return $table
            ->query(
                Customer::query()
                    ->where('total_spent', '>', 0)
                    ->orderByDesc('total_spent')
                    ->limit(5)
            )
            ->columns([
                Tables\Columns\TextColumn::make('full_name')
                    ->label('Customer')
                    ->searchable(['first_name', 'last_name'])
                    ->weight('bold'),
                Tables\Columns\TextColumn::make('order_count')
                    ->label('Orders')
                    ->badge()
                    ->color('primary'),
                Tables\Columns\TextColumn::make('total_spent')
                    ->label('Total Spent')
                    ->money('USD')
                    ->color('success')
                    ->weight('bold'),
                Tables\Columns\TextColumn::make('last_order_date')
                    ->label('Last Order')
                    ->dateTime('M j, Y')
                    ->color('gray'),
            ])
            ->recordActions([
                Action::make('view')
                    ->url(fn (Customer $record): string => "/admin/customers/{$record->id}")
                    ->icon('heroicon-m-eye'),
            ])
            ->paginated(false)
            ->poll('60s');
    }
}