shadcn.io is not affiliated with official shadcn/ui
Sparkline Range Card Stats Block for React
A price inside its 52-week range for a trading journal: a line between two labelled hairlines for the high and the low, today's close as a dot, and the position in the range as a percent and a meter.
Installation
Overview
A sparkline card with a range for React with Base UI. A start-aligned header says how far up its 52-week range an index sits, "Tern 50 sits 76% of the way up its range", and a split follows. At the start, the 52-week low, the 52-week high and today's close as a list, each with when it happened. At the end, a framed figure (a hairline frame with a + on each corner): 52 weekly closes as a line under a soft fade, between two hairlines that carry the high and the low on their own labels, a hollow dot where the line touches each and a filled one on today's close with its value beside it. Under the chart, the position in the range as a big percent and a meter. Everything is computed from one series of weekly closes, so the text and the drawing agree. On a phone the figure comes before the list. The figures are an example from a fictional index, not advice. It is built from Guides, hand-drawn SVG and CSS transitions.
FAQ
How do I change the data?
Edit LOW and HIGH for the range and ANCHORS for the shape of the year (each entry is a week and a position from 0 to 1). The weekly closes are that shape plus a little seeded noise, fitted so the lowest close is exactly LOW and the highest HIGH; replace CLOSES with your own 52 values and everything else is found from them: the dots, the labels, the percent and the list.
How is the position worked out?
It is today's close less the low, over the high less the low, rounded to a whole percent. The headline, the readout and the meter all use that one number. The meter is a drawing, hidden from assistive technology, because the readout beside it says the same in words.
Is it accessible?
Yes. The line is an image whose name gives the low and the high with how long ago each was, and this week's close. The same numbers are in the list at the start, a description list, and the labels on the hairlines are text. The chart is dir="ltr" and values sit in bdi elements.
Why is it all one colour?
The chart uses your theme's text colour at a few weights, with the range lines as plain hairlines, so it is correct in every preset, light and dark, and readable without colour.
Related
- 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
Dual Series Sparkline Stats
SparklinesThis week's opens against last week's on one scale, with a switch that shows or hides the second line, its total and the difference.
- Pro
Line Chart With Threshold Stats
Area and lineA latency line against its 300 ms SLO for an API monitor: the stretches over the threshold are drawn thicker with ringed points, and a rail repeats the breaches, the time over and the worst reading in text.
- Pro
Area Chart With Reference Area Stats
Area and lineAn area chart of alert delivery time with the incident drawn as a shaded window between two hairlines, and three rows beside it: how long it lasted, the peak delay and the alerts it touched.
- Pro
Benchmark Scale Stats
DistributionsFive support metrics, each on a scale line with three markers (your team as a solid dot, the industry average as a ring, the top 10% as a tick), a verdict with a glyph and words, and the three values as text.
- Pro
Sparkline Hero Metric Stats
Hero metricA 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.