MetricCard

Unified display component handling 9 variants via a discriminated union on the variant prop. All variants share a Zone A/B/C layout with dynamic font sizing, trend indicators, and background visualizations.

All 9 Variants
Standard
Total Revenue
$125.4K
MTD▲13%
Timeframe
Sparkline
Daily Orders
847
MTD▼3%
Timeframe
Bars
Monthly Trend
$94.2K
QTD▲8%
Timeframe
Donut
Order Fill Rate
78%
MTD▲2.1%
Timeframe
Highlight
Top Performer
$42.9K
Sarah Mitchell▲28%
Timeframe
Arrow
Growth Indicator
▲
18%
YoY▲18%
Timeframe
Object Arrow
Fulfillment Rate
5%
85%
MTD▲5%
Timeframe
Versus
Revenue Comparison
$125.4KThis Year

$98.7KLast Year
YoY
Timeframe
Segmented
Category Mix
312 SKUs
Active Items
Furniture
Lighting
Textiles
Other
Timeframe
Highlight
Warehouse Capacity
87%
Approaching limit▲4%
Timeframe
Highlight
Return Rate
6.80%
Above threshold▲1.9%
Timeframe
Highlight
Pending Reviews
24
Awaiting QA
Timeframe

State Toggles

Total Revenue
$125.4K
MTD▲13%
Timeframe
State: normal

Usage

JSX
import { MetricCard, CardShell } from '@so.boss/gloss-ui';
import type { MetricCardProps } from '@so.boss/gloss-ui';

// Standard variant
<CardShell>
  <MetricCard
    variant="standard"
    label="Total Revenue"
    value={125430}
    valueFormat={{ prefix: '$', abbreviated: true }}
    trend={{ value: 12.5, direction: 'up' }}
    subtitle="MTD"
  />
</CardShell>

// Sparkline variant
<CardShell>
  <MetricCard
    variant="sparkline"
    label="Daily Orders"
    value={847}
    sparklineData={[42, 38, 51, 47, 55, 60, 58, 63]}
    trend={{ value: -3.2, direction: 'down' }}
    accentColor="#6366f1"
  />
</CardShell>

// Donut variant
<CardShell>
  <MetricCard
    variant="donut"
    label="Fill Rate"
    value={78}
    valueFormat={{ suffix: '%' }}
    donutValue={78}
    donutMax={100}
    accentColor="#10b981"
  />
</CardShell>

Props Reference

Base Props (all variants)

PropTypeDefaultDescription
variant'standard' | 'sparkline' | 'bars' | 'donut' | 'highlight' | 'arrow' | 'object-arrow' | 'versus' | 'segmented''standard'Discriminated union variant selector
labelstring—Zone A label (uppercase)
valuenumber | string | null—Primary metric value
valueFormat{ prefix?, suffix?, abbreviated? }—Value formatting options
trend{ value, direction: 'up' | 'down' | 'flat' }—Trend indicator in Zone C
isLoadingbooleanfalseShow skeleton placeholder
isErrorbooleanfalseError state indicator
isEmptybooleanfalseNo data available state
isStalebooleanfalseData is outdated (blur transition)

Variant-Specific Props

VariantExtra PropsDescription
sparklinesparklineData: number[], accentColor?Background sparkline chart
barsbarData: number[], accentColor?Background bar chart
donutdonutValue, donutMax?, accentColor?Inline donut progress chart
highlighthighlightColor: stringTinted overlay with colored value text
arrowarrowDirection: 'up' | 'down'Inline arrow direction indicator
object-arrowobjectArrowValue, objectArrowMaxCircular progress with trend arrow
versusversusData: VersusDataSide-by-side period comparison (colSpan: 2)
segmentedsegments: SegmentEntry[]Stacked segment bar with labels (colSpan: 2)