StatsOverviewWidget
import { StatsOverviewWidget, Stat, pageFilters, html } from '@shamar/core'
export class ProductStatsWidget extends StatsOverviewWidget { static override sort = 10 static override columnSpan = 'full' static override heading = 'Analytics' static override description = 'An overview of some analytics.' /** Cards per row (Filament getColumns). null = auto from count. */ static override columns = 4 /** Filament defaults: lazy + poll every 5s. */ static override isLazy = false static override pollingInterval: string | null = '5s'
static override async stats(ctx) { const filters = pageFilters(ctx) // dashboard filtersForm values return [ Stat.make('Total products', count) .description('32k increase') .descriptionIcon('arrow-trending-up') .icon('cube') .color('success') .chart([7, 2, 10, 3, 15, 4, 17]) .url('/admin/products') .openUrlInNewTab() .extraAttributes({ class: 'cursor-pointer' }) .columnSpan(1), Stat.make('Views', null).placeholder('—'), Stat.make('Note', html('<strong>HTML</strong> value')), ] }}Scaffold with:
node ace shamar:make-widget ProductStats --type=statsDashboard filters
Section titled “Dashboard filters”class AdminDashboard extends DashboardPage { static override filtersForm(form) { return form.schema([ Select.make('period').options([ { label: 'Today', value: 'today' }, { label: 'MTD', value: 'mtd' }, ]), ]) } static override widgets() { return [ProductStatsWidget] }}Widget
| Method | Description |
|---|---|
static sort | Grid order. |
static columnSpan | 1–4 or full width on the dashboard grid. |
static columns | Cards per row: number, responsive map, or null (auto 3/4). |
static heading / description | Title and subtitle above the cards. |
static pollingInterval | '5s' default; null disables. |
static isLazy | Defer stats until visible (default true). |
static stats(ctx) | Returns Stat[] (async). Read ctx.filters / pageFilters(ctx). |
StatsOverviewWidget.configureUsing | Global defaults for all stats widgets. |
Stat
| Method | Description |
|---|---|
make / description / descriptionIcon / color / chart / url | Core card API. |
icon() | Leading card icon. |
descriptionColor() / chartColor() | Independent colors. |
placeholder() / configureUsing() | Blank value fallback. |
extraAttributes() / openUrlInNewTab() | HTML attrs and link target. |
columnSpan() | Span multiple columns in the stats grid. |
html() | Trusted HTML for label/value/description. |