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
Active Users
Revenue
Response Time
Average API response time
Props#
UnifiedMetricsProps#
| Prop | Type | Default | Description |
|---|---|---|---|
title | string | "Key Metrics" | Title displayed above metrics |
metrics | UnifiedMetric[] | required | Array of metric objects |
layout | 'grid' | 'horizontal' | 'vertical' | 'grid' | Layout style |
columns | 1 | 2 | 3 | 4 | 3 | Number of columns in grid layout |
variant | 'default' | 'card' | 'minimal' | 'default' | Visual style variant |
size | 'sm' | 'md' | 'lg' | 'md' | Size of metric display |
showIcons | boolean | true | Show/hide icons |
showTrends | boolean | true | Show/hide trend indicators |
showDescriptions | boolean | true | Show/hide metric descriptions |
className | string | '' | Additional CSS classes |
UnifiedMetric Object#
| Property | Type | Required | Description |
|---|---|---|---|
label | string | ✅ | Metric label/name |
value | string | number | ✅ | Metric value |
icon | string | 'trending' | 'users' | 'dollar' | 'target' | 'clock' | 'zap' | ❌ | Icon to display |
color | 'blue' | 'green' | 'purple' | 'red' | 'yellow' | 'indigo' | 'gray' | ❌ | Color theme |
trend | string | ❌ | Trend value (e.g., "+12%") |
trendDirection | 'up' | 'down' | 'neutral' | ❌ | Trend direction indicator |
description | string | ❌ | Additional description text |
tooltip | string | ❌ | Tooltip text (future feature) |
Variants#
Default Variant#
Standard metrics display with white background:
Key Metrics
Total Projects
Years Experience
Technologies
Card Variant#
Elevated cards with colored backgrounds:
Key Metrics
API Calls
Uptime
Minimal Variant#
Clean, minimal design for subtle metrics display:
Key Metrics
Sizes#
Control the size of metrics display. Same metrics, three size values:
Key Metrics
Total Projects
Years Experience
Technologies
Key Metrics
Total Projects
Years Experience
Technologies
Key Metrics
Total Projects
Years Experience
Technologies
Layouts#
Same metrics, three layout values — grid (default), horizontal, and vertical:
Key Metrics
Total Projects
Years Experience
Technologies
Key Metrics
Total Projects
Years Experience
Technologies
Key Metrics
Total Projects
Years Experience
Technologies
Icons#
Available built-in icons:
trending- TrendingUp iconusers- Users icondollar- DollarSign icontarget- Target iconclock- Clock iconzap- Zap (lightning) icon
Key Metrics
Users
Revenue
Speed
Colors#
Available color themes:
blue- Primary bluegreen- Success greenpurple- Info purplered- Error/warning redyellow- Warning yellowindigo- Accent indigogray- Neutral gray
Key Metrics
Success
Pending
Failed
Trends#
Add trend indicators to show metric changes:
Key Metrics
Revenue
Compared to last quarter
Load Time
Performance improved
Traffic
Stable traffic
Migration from Old Components#
The deprecated components below are thin wrappers around UnifiedMetrics — each pair renders identically.
From MetricsCard#
Performance
Total Projects
Years Experience
Technologies
From MetricsGrid#
Key Metrics
API Calls
Uptime
From StatsGrid#
Key Metrics
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
Lines of Code
Production codebase
Test Coverage
Unit + integration tests
Build Time
Optimized build pipeline
Performance Dashboard#
System Performance
CPU
Memory
Requests/s
Uptime
Business KPIs#
Q4 Business Metrics
Revenue
Year-over-year growth
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#
- Keep metrics focused: Show 3-6 key metrics, not dozens
- Use consistent units: "$1M" not "$1,000,000"
- Choose appropriate colors: Green for positive, red for alerts
- Add descriptions: Help users understand what metrics mean
- Show trends: Context helps users understand if metrics are improving
Related Components#
- Timeline - For temporal data visualization
- FeatureGrid - For feature comparison
- ComparisonTable - For detailed comparisons
TypeScript Types#
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;
}