Stat Card

A KPI tile with a value, a trend badge and a caption.

StatCard is new in v0.4. It shows one metric: a title, the value, an optional change badge coloured by trend, and a description.

Installation

bash
shellui add stat-card

Usage

Basic

Revenue

$45,231

+20.1%

vs last month

<div class="w-full max-w-xs">
    <StatCard Title="Revenue" Value="$45,231" Change="+20.1%" Trend="up" Description="vs last month" />
</div>

Trend colours the Change badge: up is green, down is red, and anything else is neutral. It doesn't read the sign of Change, so a falling error rate can still be up if that's good news.

With an icon

Subscriptions

1,204

+12%

since last week

Orders

318

-4%

since last week

<div class="grid gap-4 sm:grid-cols-2">
    <StatCard Title="Subscriptions" Value="1,204" Change="+12%" Trend="up" Description="since last week">
        <Icon>
            <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
                <path stroke-linecap="round" stroke-linejoin="round" d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2M9 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8ZM22 21v-2a4 4 0 0 0-3-3.87M16 3.13a4 4 0 0 1 0 7.75" />
            </svg>
        </Icon>
    </StatCard>
    <StatCard Title="Orders" Value="318" Change="-4%" Trend="down" Description="since last week">
        <Icon>
            <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
                <path stroke-linecap="round" stroke-linejoin="round" d="M6 2 3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4ZM3 6h18M16 10a4 4 0 0 1-8 0" />
            </svg>
        </Icon>
    </StatCard>
</div>

Extra content

Anything inside the card renders below the description.

Storage

72 GB

of 100 GB used

<div class="w-full max-w-xs">
    <StatCard Title="Storage" Value="72 GB" Description="of 100 GB used">
        <Progress Value="72" Class="mt-3" />
    </StatCard>
</div>

API Reference

Parameter Type Default Description
Title string? null The metric's name
Value string? null The value, already formatted
Change string? null Text for the badge, such as +20.1%
Trend string "neutral" Badge colour: up, down or neutral
Description string? null Caption under the value
Icon RenderFragment? null Icon in the top-right corner
ChildContent RenderFragment? null Content below the description
Class string? null Additional CSS classes

Accessibility

  • Trend is shown by colour only, so keep the sign or a word in Change (+20.1%, down 4%)
  • Decorative icons need no label; give a meaningful icon an aria-label

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.