shadcn.io is not affiliated with official shadcn/ui
Sparkline Hero Metric Stats Block for React
A hero figure for a cash-planning tool beside its own 90-day trend: the runway in months at the start, and a wide line with its high, its low and today marked.
Installation
Overview
A hero metric with a sparkline for React with Base UI. A start-aligned header says where the runway stands ("Runway is back to 14.2 months") and how far it is above its low. Under it, one two-cell band runs from rail to rail and ends the block. At the start, the figure as a big number that rolls up once, its change on 30 days ago, and the cash and monthly burn it comes from. At the end, twice as wide, a 90-day line of the runway under a soft fade, with the high and the low each marked by a hollow dot and a label, today by a filled dot, and the span written under it. The headline, the change, the line, the marks and the line's text alternative are all computed from one series of daily readings (cash divided by burn gives today's value), so they always agree. The two cells sit side by side from lg and stack below it. It is built from Guides, the Sliding Number, hand-drawn SVG and CSS transitions. For finance, capacity and any figure that needs its own history.
FAQ
How do I change the data?
Edit CASH and BURN for today's reading and ANCHORS for the shape of the 90 days: each entry is a day and a runway in months, and the days between are drawn on straight lines between them with a little seeded noise (a fixed sequence, so the server and the browser draw the same line). Replace readingsOf with your own array of 90 readings if you have real data; the high, the low, the marks and the headline are found from it.
How are the high and the low marked?
They are the series' highest and lowest readings, found when the module loads. Each is a hollow dot and a label positioned in HTML from the same coordinates as the line; a label near an edge is aligned to that edge so it never spills out of the box.
Is it accessible?
Yes. The figure is a description list. The line is an image whose name gives where it starts, its high and its low with how long ago each was, and today's value. The dots and labels are text beside it, and the box is dir="ltr" because time reads from the start to the end in every language.
Why is it all one colour?
Direction is told by an arrow and a sign, and the chart is in your theme's text colour at two weights, so it works in every preset, light and dark, and without colour.
Related
- Pro
Hero Metric Card Stats
Hero metricOne headline figure for a treasury tool, cash on hand in a big number inside a card in a card, with a change pill, a comparison and a two-line footnote that says when it was read and from where.
- Pro
Delta Arrow Hero Metric Stats
Hero metricA hero figure for an ad-spend tool beside an oversized arrow whose angle is the slope of the change, with a pill for the percent and its comparison.
- Pro
Sparkline Stats
SparklinesThree sparkline cells for a web-analytics tool, each with its figure for the last seven days, its change on the seven before and thirty days of line under a soft fade.
- Pro
Area Chart Hero Stats
Area and lineA rail-to-rail area chart for a farm-shop sales tool: twelve months of sales fading out toward the foot, with the latest month's figure and its change laid over the top corner.
- Pro
KPI Bar with Trends Stats
KPI bands and tilesFour figures for a garden-centre analytics tool in cells that share their hairlines, each with its change on the week before and an area chart that runs to the cell's edges and foot.
- $48,110Pro
A revenue banner for a sales dashboard, as a card in card: the figure, a change badge and the comparison at the start, a 24 h and 7 d switch and a bar sparkline at the end, swapping in place.