Stat cards
Highlights a single number with its label, an icon and its change from the previous period.
zb:stat-card zubazar/ui · free (MIT)
Basic usage
label and value are required; the value is shown as is, so add the thousands separator or the unit yourself.
<zb:stat-card label="Total customers" value="4,812" />
| Prop | Values |
|---|---|
label | Description of the number |
value | Displayed value |
Change
change shows the percentage change (0 and above green, negative red); change-label adds a short note next to it.
<div class="grid gap-4 sm:grid-cols-3">
<zb:stat-card label="Orders this month" value="3,106" :change="12.5" change-label="vs. last month" />
<zb:stat-card label="Returns" value="214" :change="-4" change-label="vs. last month" />
<zb:stat-card label="Open tickets" value="38" :change="0" />
</div>
| Prop | Values |
|---|---|
change | Percentage; 0 and above green, negative red |
change-label | Text next to the change |
Icon and colors
icon is shown in a colored box at the top left; color picks the box color (default brand).
<div class="grid gap-4 sm:grid-cols-2 lg:grid-cols-5">
<zb:stat-card label="Total customers" value="4,812" icon="users" />
<zb:stat-card label="Delivered" value="3,106" icon="truck" color="success" />
<zb:stat-card label="Returns" value="214" icon="exclamation-triangle" color="warning" />
<zb:stat-card label="Canceled" value="12" icon="x-circle" color="danger" />
<zb:stat-card label="Open tickets" value="38" icon="ticket" color="info" />
</div>
| Prop | Values |
|---|---|
icon | zb:icon name |
color | brand | success | warning | danger | info |
Value colour and hint
value-color colours a figure that is good or bad by itself; hint adds a short note under the value.
<div class="grid gap-4 sm:grid-cols-3">
<zb:stat-card label="Profit" value="$48,210" value-color="success" hint="Target: $45,000" />
<zb:stat-card label="Return rate" value="6.4%" value-color="danger" hint="Last month 4.1%" />
<zb:stat-card label="Pending orders" value="35" hint="12 in transit" />
</div>
| Prop | Values |
|---|---|
value-color | success | danger | warning | info… |
hint | The note under the value |
Extra content
The actions slot sits in the top right corner and the default slot at the bottom of the card; use it for a progress bar or a small chart.
<zb:stat-card label="Monthly target" value="3,106 / 3,400" icon="flag">
<zb:slot:actions>
<zb:badge variant="info">September</zb:badge>
</zb:slot:actions>
<zb:progress :value="91" size="sm" label="91 percent of the monthly target" />
</zb:stat-card>
| Prop | Values |
|---|---|
actions | Slot; top right |
default slot | Bottom of the card |
Props
The values the component takes. What are props and slots?
| Prop | Type | Default | Description |
|---|---|---|---|
label | — | — | Required; description of the number |
value | — | — | Required; displayed value |
change | — | null | Percentage change; red when negative |
change-label | — | null | Text next to the change |
icon | — | null | zb:icon name |
color | — | primary | primary · secondary · success · danger · warning · info · dark (icon box; brand = primary) |
value-color | — | null | The value's colour: success · danger · warning · info…; null the text colour |
hint | — | null | A short note under the value |
Slots: actions (top right), default content (bottom of the card)
Developer notes
- The
changenumber is formatted for the application locale, with at most one decimal place.