jbmui

StatCard

  • UI

One number with its context on a raised Card: mono label, large value, and a short sub line, stacked or in a row.

Contexto
1M
tokens
0.8s
Latencia
p50

Install

npx shadcn@latest add @jbm/stat-card

Needs the @jbm entry in components.json; see Install once.

Also installs @jbm/tokens, @jbm/card.

Usage

Stacked and row cards
import { StatCard } from "@/jbm/ui/stat-card"<StatCard label="Contexto" value="1M" sub="tokens" w={620} h={245} /><StatCard row label="Latencia" value="0.8s" sub="p50" w={620} h={140} />
Ink value beside another accent
import { StatCard } from "@/jbm/ui/stat-card"import { color } from "@/jbm/lib/tokens"<StatCard label="Precisión" value="86%" valueColor={color.ink} />

Props

Stage px
Declared at the documented defaults
Landscape
520 by 300
Vertical
520 by 300
Basis

Card is border-box, so the defaults w=520 and h=300 are the outer size in either orientation. For vertical stages SceneFromSpec renders row cards at the full content width (936) and h=180, and the gallery shows w=620 with h=245 stacked and h=140 in a row.

Fixed-size Card (border-box) holding a mono label, an 800-weight value, and an optional sub line. Stacked by default for landscape; row puts the value (fixed 400px column) beside the label and sub for vertical stages.

PropTypeDefaultDescription
labelstringrequiredMono caption naming the number, 22px in the dim color.
valueReact.ReactNoderequiredThe number or short value; 96px stacked, 84px in row mode, -3px tracking.
substringnoneOptional one-line context under the label (row) or under the value (stacked); dim when stacked, ink in row mode.
valueColorstringcolor.accentValue color; defaults to the vermilion accent. Use color.ink when another element already carries the accent.
wnumber520Card width in stage pixels, including padding and border.
hnumber300Card height in stage pixels, including padding and border.
rowbooleanfalseLays value, then label and sub, side by side with 22×34px padding and a 30px gap; the scene compiler uses it for vertical stages.
styleReact.CSSPropertiesnoneInline styles merged after the size and row layout.

QA checks

  • Content does not fit itself: check the widest value and longest sub stay inside w×h in both layouts, since the card has a fixed height and does not clip or shrink text.
  • In row mode the value column is a fixed 400px; with w below about 500 the label and sub have almost no room.
  • Compare stacked landscape and row vertical cards on cream: fine border, layered shadow, and inset highlight come from Card.