Skip to content

MetricCard

Versatile card for displaying metrics with multiple layouts, appearances, and data enhancers.

Props

MetricCardProps

PropTypeDefaultDescription
titlestringRequiredMetric label
valuestring | numberRequiredMetric value
subtitlestring-Additional context
iconLucideIcon-Icon component
iconClassNamestring-Icon container class
variantMetricCardVariant'default'Semantic color variant
layoutMetricCardLayout'standard'Structural layout
appearanceMetricCardAppearance'soft'Visual skin
trendMetricCardTrend-Trend indicator
progressMetricCardProgress-Progress bar
chartMetricCardChart-Mini chart
actionLabelstring-Action link text
onAction() => void-Action click handler
classNamestring-Card container class
childrenReactNode-Custom content (split layout)

Layout Variants

ts
type MetricCardLayout = 'compact' | 'standard' | 'split' | 'centered' | 'inline';
LayoutDescription
compactMinimal KPI, horizontal with small icon
standardDefault layout with icon on right
splitValue on left, chart/content on right
centeredCentered value for totals, gauges
inlineHorizontal row for lists

Appearance Variants

ts
type MetricCardAppearance = 'soft' | 'solid' | 'gradient' | 'glass' | 'dark';
AppearanceDescription
softLight background, subtle borders
solidFlat background, higher contrast
gradientSoft gradient backgrounds
glassGlassmorphism with blur
darkDark mode optimized with glow

Color Variants

ts
type MetricCardVariant = 'default' | 'primary' | 'success' | 'warning' | 'danger' | 'info';

Data Enhancers

MetricCardTrend

ts
interface MetricCardTrend {
  value: number;
  direction: 'up' | 'down';
  label?: string;
}

MetricCardProgress

ts
interface MetricCardProgress {
  value: number;
  max?: number;      // default: 100
  showLabel?: boolean;
}

MetricCardChart

ts
interface MetricCardChart {
  type: 'bar' | 'line' | 'area';
  data: number[];
  color?: string;
}

Examples

Basic Usage

tsx
<MetricCard
  title="Total Revenue"
  value="$45,678"
  icon={DollarSign}
  variant="success"
/>

With Trend and Chart

tsx
<MetricCard
  title="Weekly Sales"
  value="$23,540"
  layout="split"
  appearance="gradient"
  variant="primary"
  trend={{ value: 12.5, direction: 'up', label: 'vs last week' }}
  chart={{ type: 'area', data: [10, 25, 15, 30, 45, 35, 50] }}
/>

Centered with Progress

tsx
<MetricCard
  title="Goal Progress"
  value="67%"
  layout="centered"
  appearance="glass"
  icon={Target}
  progress={{ value: 67, max: 100, showLabel: true }}
/>

Dark Appearance

tsx
<MetricCard
  title="Earned Today"
  value="$960"
  appearance="dark"
  variant="primary"
  trend={{ value: 12, direction: 'up' }}
  chart={{ type: 'bar', data: [720, 850, 920, 780, 960] }}
/>

Compact Layout

tsx
<MetricCard
  title="Active Users"
  value="1,234"
  icon={Users}
  layout="compact"
  trend={{ value: 8.5, direction: 'up' }}
/>

See also