Stat
Stat presents a key metric in a compact card with an optional trend and supporting caption.
Usage
Open tickets 24
<script> import { Stat } from 'deskblocks'; </script> <Stat label="Open tickets" value="24" />
With a caption
The sub prop adds a muted helper line under the value.
Avg. first response 1h 12m
<Stat label="Avg. first response" value="1h 12m" sub="last 7 days" /> Trend
Pass trend to display a delta pill. The direction sets its arrow and color: up uses success, down uses danger and flat uses neutral. Pass the already formatted change as value .
Resolved today 38
SLA compliance 86%
Happiness 94%
<div style="display: grid; grid-template-columns: repeat(3, minmax(160px, 1fr)); gap: 12px; align-items: start;" > <Stat label="Resolved today" value="38" trend={{ direction: 'up', value: '+12%' }} sub="vs yesterday" /> <Stat label="SLA compliance" value="86%" trend={{ direction: 'down', value: '-8%' }} sub="vs last week" /> <Stat label="Happiness" value="94%" trend={{ direction: 'flat', value: '±0%' }} /> </div>
Cards stretch to the row height (align-self: stretch ), so stats placed side by side in a grid stay equal-height even when some have no caption.
Custom value slot
Use the value slot instead of the value prop when the metric area needs markup, such as a spinner while the figure loads.
Open tickets
<script> import { Stat, Spinner } from 'deskblocks'; </script> <Stat label="Open tickets"> <Spinner slot="value" size="small" /> </Stat>
Slots
value: replaces the value text, for example aSpinnerwhile the figure loads.
Props
label | string | Required | Small caption shown above the value. |
value | string | number | undefined | Pre-formatted KPI value. Ignored when the value slot is used. |
sub | string | undefined | Muted helper line shown after the trend pill. |
trend | StatTrend | undefined | Optional delta pill with a direction and display-ready value. |
class | string | undefined | Custom CSS class name for additional styling. |
type StatTrend = {
direction: 'up' | 'down' | 'flat';
value: string;
};