Stat Card

KPI tiles whose headline numbers roll digit by digit to each new value, with Intl number, currency, percent and compact formatting, a delta badge with an up or down arrow toned by whether the move is good news, an inline sparkline that redraws when its data changes, a period caption, a skeleton loading state and a container-query StatGrid layout.

Preview

Stat Card preview width

Install

Add it with the shadcn CLI, or copy the source manually.

$ bunx --bun shadcn add @karaui/stat-card
@karaui not found? Add it to components.json
{
  "registries": {
    "@karaui": "https://karaui.kamisama-v0.my.id/r/{name}.json"
  }
}

@karaui is in shadcn's public registry directory, so the latest CLI needs no setup. On an older CLI, merge this into the existing file once and every @karaui/… install resolves.

API Reference

StatCard

label
ReactNode
—
value
number

Headline value. For `format="percent"` pass a fraction (0.034 = 3.4%).

—
format?
"number" | "percent" | "compact" | "currency"

Preset formatting. Default "number".

number
currency?
string

ISO 4217 code for `format="currency"`. Default "USD".

USD
locale?
string

Formatting locale. Default "en-US" so server and client agree.

en-US
formatOptions?
NumberFormatOptions

Extra Intl options merged over the preset (e.g. fraction digits).

—
delta?
number

Relative change as a fraction (0.12 = +12%). Omit to hide the badge.

—
goodDirection?
"up" | "down"

Which direction is good news. Default "up"; use "down" for churn, latency…

up
deltaTone?
"neutral" | "positive" | "negative"

Force the badge tone instead of deriving it from delta and goodDirection.

—
sparkline?
number[]

Trend values for the inline sparkline.

—
sparklineColor?
string

Sparkline color (any CSS color). Default follows the delta tone.

—
caption?
ReactNode

Small caption under the value, e.g. "vs previous 30 days".

—
icon?
ReactNode

Optional icon beside the label.

—
loading?
boolean

Render a skeleton instead of the value.

false
className?
string
—

StatGrid

className?
string
—

Keep in mind

Some components on this site are inspired by or recreated from existing work across the web. I'm not here to take credit; just to learn, experiment, and sometimes push things a bit further. If something looks familiar and I forgot to mention you, reach out and I'll fix that right away.

Updated