Skip to content
Shamar

StatsOverviewWidget

From the /demo dashboard widget grid.
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:

Terminal window
node ace shamar:make-widget ProductStats --type=stats
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

MethodDescription
static sortGrid order.
static columnSpan1–4 or full width on the dashboard grid.
static columnsCards per row: number, responsive map, or null (auto 3/4).
static heading / descriptionTitle and subtitle above the cards.
static pollingInterval'5s' default; null disables.
static isLazyDefer stats until visible (default true).
static stats(ctx)Returns Stat[] (async). Read ctx.filters / pageFilters(ctx).
StatsOverviewWidget.configureUsingGlobal defaults for all stats widgets.

Stat

MethodDescription
make / description / descriptionIcon / color / chart / urlCore 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.