Skip to main content
Skip to main content

UnifiedMetrics

Consolidated component for displaying metrics, statistics, and KPIs

UnifiedMetrics#

The UnifiedMetrics component is a powerful, consolidated solution for displaying metrics, statistics, and KPIs. It replaces four previous components (MetricsCard, MetricsGrid, StatsGrid, StatsOverview) with a single, flexible component.

Bundle Size Reduction

By consolidating multiple metrics components into one, we achieved a 46% reduction in bundle size for metrics-related code.

Basic Usage#

Key Performance Metrics

10,000++12%

Active Users

$2.5M+25%

Revenue

< 100ms-15%

Response Time

Average API response time

Props#

UnifiedMetricsProps#

PropTypeDefaultDescription
titlestring"Key Metrics"Title displayed above metrics
metricsUnifiedMetric[]requiredArray of metric objects
layout'grid' | 'horizontal' | 'vertical''grid'Layout style
columns1 | 2 | 3 | 43Number of columns in grid layout
variant'default' | 'card' | 'minimal''default'Visual style variant
size'sm' | 'md' | 'lg''md'Size of metric display
showIconsbooleantrueShow/hide icons
showTrendsbooleantrueShow/hide trend indicators
showDescriptionsbooleantrueShow/hide metric descriptions
classNamestring''Additional CSS classes

UnifiedMetric Object#

PropertyTypeRequiredDescription
labelstringMetric label/name
valuestring | numberMetric value
iconstring | 'trending' | 'users' | 'dollar' | 'target' | 'clock' | 'zap'Icon to display
color'blue' | 'green' | 'purple' | 'red' | 'yellow' | 'indigo' | 'gray'Color theme
trendstringTrend value (e.g., "+12%")
trendDirection'up' | 'down' | 'neutral'Trend direction indicator
descriptionstringAdditional description text
tooltipstringTooltip text (future feature)

Variants#

Default Variant#

Standard metrics display with white background:

Key Metrics

50+

Total Projects

10+

Years Experience

25+

Technologies

Card Variant#

Elevated cards with colored backgrounds:

Key Metrics

1M/day

API Calls

99.9%

Uptime

Minimal Variant#

Clean, minimal design for subtle metrics display:

Key Metrics

24/7
Active
Healthy
Status

Sizes#

Control the size of metrics display. Same metrics, three size values:

Key Metrics

50+

Total Projects

10+

Years Experience

25+

Technologies

Key Metrics

50+

Total Projects

10+

Years Experience

25+

Technologies

Key Metrics

50+

Total Projects

10+

Years Experience

25+

Technologies

Layouts#

Same metrics, three layout values — grid (default), horizontal, and vertical:

Key Metrics

50+

Total Projects

10+

Years Experience

25+

Technologies

Key Metrics

50+

Total Projects

10+

Years Experience

25+

Technologies

Key Metrics

50+

Total Projects

10+

Years Experience

25+

Technologies

Icons#

Available built-in icons:

  • trending - TrendingUp icon
  • users - Users icon
  • dollar - DollarSign icon
  • target - Target icon
  • clock - Clock icon
  • zap - Zap (lightning) icon

Key Metrics

10K

Users

$1M

Revenue

Fast

Speed

Colors#

Available color themes:

  • blue - Primary blue
  • green - Success green
  • purple - Info purple
  • red - Error/warning red
  • yellow - Warning yellow
  • indigo - Accent indigo
  • gray - Neutral gray

Key Metrics

100%

Success

5

Pending

0

Failed

Add trend indicators to show metric changes:

Key Metrics

$1.5M+25%

Revenue

Compared to last quarter

1.2s-30%

Load Time

Performance improved

100K0%

Traffic

Stable traffic

Migration from Old Components#

The deprecated components below are thin wrappers around UnifiedMetrics — each pair renders identically.

From MetricsCard#

Performance

50+

Total Projects

10+

Years Experience

25+

Technologies

From MetricsGrid#

Key Metrics

1M/day

API Calls

99.9%

Uptime

From StatsGrid#

Key Metrics

24/7
Active
Healthy
Status

Backward Compatibility

Deprecated components still work for backward compatibility, but we recommend migrating to the new unified components for better performance and maintainability.

Real-World Examples#

Project Metrics#

Project Impact

50K+

Lines of Code

Production codebase

95%+10%

Test Coverage

Unit + integration tests

< 2min-40%

Build Time

Optimized build pipeline

Performance Dashboard#

System Performance

45%

CPU

2.1 GB

Memory

1.2K

Requests/s

99.9%

Uptime

Business KPIs#

Q4 Business Metrics

$2.5M+25%

Revenue

Year-over-year growth

4.8/5.0+0.3

Customer Satisfaction

Average rating from 5,000+ reviews

Accessibility#

  • ✅ Keyboard navigable
  • ✅ Screen reader friendly
  • ✅ ARIA labels included
  • ✅ Color-blind safe color schemes
  • ✅ High contrast mode support

Performance#

  • Bundle size: ~2.5KB gzipped
  • Zero runtime dependencies (uses Lucide React icons)
  • Optimized for React 18+ with concurrent rendering
  • Lazy loading support

Dark Mode#

All variants automatically adapt to dark mode with no additional configuration needed.

Best Practices#

  1. Keep metrics focused: Show 3-6 key metrics, not dozens
  2. Use consistent units: "$1M" not "$1,000,000"
  3. Choose appropriate colors: Green for positive, red for alerts
  4. Add descriptions: Help users understand what metrics mean
  5. Show trends: Context helps users understand if metrics are improving

TypeScript Types#

TypeScript
interface UnifiedMetric {
  label: string;
  value: string | number;
  icon?: string | 'trending' | 'users' | 'dollar' | 'target' | 'clock' | 'zap';
  color?: 'blue' | 'green' | 'purple' | 'red' | 'yellow' | 'indigo' | 'gray';
  trend?: string;
  trendDirection?: 'up' | 'down' | 'neutral';
  description?: string;
  tooltip?: string;
}

interface UnifiedMetricsProps {
  title?: string;
  metrics: UnifiedMetric[];
  layout?: 'grid' | 'horizontal' | 'vertical';
  columns?: 1 | 2 | 3 | 4;
  variant?: 'default' | 'card' | 'minimal';
  size?: 'sm' | 'md' | 'lg';
  showIcons?: boolean;
  showTrends?: boolean;
  showDescriptions?: boolean;
  className?: string;
}
Previous
First page
Next
Last page