hydroxy

Metric card

One KPI with its change against the previous value and a trend sparkline. The change shows as a sign, an arrow and a status colour together, and higher_is_better flips the colours for measures like latency.

Weekly revenue

$48.4k

+6.8%vs last week
Weekly revenue
PointValue
Current$48.4k
vs last week$45.3k
Week 1$38.2k
Week 2$39.0k
Week 3$40.1k
Week 4$39.4k
Week 5$41.8k
Week 6$42.5k
Week 7$43.0k
Week 8$42.2k
Week 9$44.9k
Week 10$46.1k
Week 11$45.3k
Week 12$48.4k
p95 latency

168ms

−1.8%vs last week
p95 latency
PointValue (ms)
Current168
vs last week171
Week 1212
Week 2205
Week 3220
Week 4198
Week 5190
Week 6186
Week 7192
Week 8181
Week 9176
Week 10179
Week 11171
Week 12168
Error rate

0.71%

+12.7%vs last week
Error rate
PointValue (%)
Current0.71
vs last week0.63
Week 10.42
Week 20.38
Week 30.40
Week 40.44
Week 50.51
Week 60.48
Week 70.55
Week 80.61
Week 90.58
Week 100.66
Week 110.63
Week 120.71

Usage

use hydroxy_leptos::metric_card::MetricCard;
use leptos::prelude::*;

pub fn demo() -> AnyView {
    let weeks: Vec<String> = (1..=12).map(|w| format!("Week {w}")).collect();
    let revenue = vec![38.2, 39.0, 40.1, 39.4, 41.8, 42.5, 43.0, 42.2, 44.9, 46.1, 45.3, 48.4];
    let latency = vec![212.0, 205.0, 220.0, 198.0, 190.0, 186.0, 192.0, 181.0, 176.0, 179.0, 171.0, 168.0];
    let errors = vec![0.42, 0.38, 0.40, 0.44, 0.51, 0.48, 0.55, 0.61, 0.58, 0.66, 0.63, 0.71];

    view! {
        <div style="display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));">
            <MetricCard
                label="Weekly revenue"
                value=48.4
                previous=45.3
                comparison="vs last week"
                trend=revenue
                trend_labels=weeks.clone()
                format=|v: f64| format!("${v:.1}k")
            />
            <MetricCard
                label="p95 latency"
                value=168.0
                previous=171.0
                unit="ms"
                comparison="vs last week"
                higher_is_better=false
                trend=latency
                trend_labels=weeks.clone()
            />
            <MetricCard
                label="Error rate"
                value=0.71
                previous=0.63
                unit="%"
                comparison="vs last week"
                higher_is_better=false
                trend=errors
                trend_labels=weeks
                format=|v: f64| format!("{v:.2}")
            />
        </div>
    }
    .into_any()
}

Anatomy

Componentdata-partRenders
MetricCardrootcard with a screen-reader table of the figures and trend
figureThe value and unit
deltaArrow, signed change and comparison; data-tone is good, bad or neutral
sparkFocusable sparkline; arrow keys step through points
tooltipPoint name and value under the pointer or focus

Keyboard

KeyDoes
ArrowRight / ArrowLeftNext or previous point on the sparkline
Home / EndFirst or last point
EscapeClear the active point

Props

PropTypeNotes
labelStringRequired. What the figure measures
valuef64Required. The current value
previousf64Value to compare against; shows the change
comparisonStringWhat the change is against, such as "vs last week"
unitStringUnit after the figure
higher_is_betterboolWhether a rise is good news. Default true
trend / trend_labelsVec<f64> / Vec<String>Sparkline values, oldest first, and their names
formatFn(f64) -> StringFormats the figure, tooltip and table
Actions
Button
Icon button
Toolbar
Theme menu
Display
Avatar
Badge
Card
Chip
Code block
Markdown
Doc card
Due pill
Kbd
Priority mark
Source chip
Space icon
Status diamond
Tag
Value diff
Carousel
Reveal
Media timeline
QR code
Transcript viewer
Audio waveform
Audio player
Forms
Calendar
Checkbox
Combobox
Date picker
Color picker
Cron builder
Theme editor
Mention input
Signature pad
Image cropper
Date field
Date range picker
Duration field
Quantity stepper
Filter chip
Input
Markdown editor
Radio group
Search field
Segmented control
Select
Slider
Range slider
Rating
Toggle button
File dropzone
Upload queue
Attachment
Switch
Tags input
Number field
Money field
Phone field
Time field
OTP input
Password field
Questionnaire
Availability picker
Voice input
Recording control
Inline edit
Async validated input
Shortcut recorder
Data
Spreadsheet grid
Week scheduler
Virtual list
Stat card
Step track
Kanban board
Sortable list
Filter builder
Data table
Grid
Access editor
File manager
Gantt chart
Log stream
Diff viewer
JSON inspector
Terminal
Node editor
Whiteboard
Navigation
Table of contents
Breadcrumb
Tabs
Wizard
Nav item
Nav section
Tree view
Pagination
Menubar
Navigation menu
Saved views
Layout
Master detail
App shell
Sidebar layout
Resizable panels
Dashboard layout
Dock layout
Feedback
Callout
Check list
Empty state
Progress bar
Toast
Approval card
Skeleton
Notification center
Bars
Bar chart
Diverging bar chart
Span chart
Pictogram chart
Stacked bar chart
Funnel chart
Bullet chart
Waffle chart
Marimekko chart
Dot plot chart
Error bar chart
Pareto chart
Waterfall chart
Lollipop chart
Grouped bar chart
Bar race chart
KPIs and frames
Chart frame
Metric card
Sparkline
Points
Scatter chart
Smith chart
Strip plot
Beeswarm chart
Parallel coordinates
Ternary chart
Bland-Altman chart
Quiver chart
Connected scatter chart
Grids and tables
Heatmap chart
Chart table
Cohort chart
Radial
Radial charts
Radar chart
Polar area chart
Stat ring
Clock chart
Spiral chart
Lines and areas
Bump chart
Slope chart
Line chart
Composed chart
Small multiples
Cycle plot chart
Horizon chart
Stacked area chart
Threshold chart
Split line chart
Linked charts
Confidence band chart
Forecast fan chart
Step chart
Range area chart
Distributions
Contour chart
Histogram
Box plot
Density chart
Ridgeline chart
Violin chart
Q-Q chart
Survival chart
ECDF chart
Raincloud plot
Forest plot
Maps
Geo map
Bubble map
Hexbin map
Cartogram
Flow map
Parts of a whole
Donut chart
Voronoi treemap
Nested donut chart
Treemap chart
Sunburst chart
Bubble pack chart
Icicle chart
Flame graph chart
Pie chart
Word cloud
Relationships
Sankey chart
Network chart
Chord chart
UpSet chart
Venn chart
Alluvial chart
Adjacency matrix chart
Dependency graph chart
Tree chart
Arc diagram
Hive plot
Edge bundling
Finance
Candlestick chart
OHLC chart
Depth chart
Renko chart
Time
Timeline chart
Calendar heatmap chart
Spectrogram chart
Marey chart
Overlays
Tour
Lightbox
Alert dialog
Command palette
Dialog
Menu
Popover
Tooltip
Sheet
Hover card
Context menu
Utilities
Pacer
Hotkeys
Disclosure
Accordion
Collapsible
Chat
Chat bubble
Voice session
Composer
Thread
Thread list
Assistant composer
Assistant MCP
Assistant modal
Assistant thread
Assistant thread list
Message scroller
Insight note
Emoji picker
Tool trace
Model picker
Citation popover
Activity
Activity feed
Comment thread
Timeline
Presence bar
Live cursors
Reaction bar
Guides
Getting started
All components
All charts