shadcn.io is not affiliated with official shadcn/ui
Split Area Chart Hero Stats Block for React
A split stats hero for a creator-membership platform: paying fans as one big rolling number with three sub-figures at the start, and at the end a twelve-week area chart you drag to read any week.
Installation
Overview
A split area-chart hero for React with Base UI. At the start, a hero panel for Kitebase, a platform where creators sell memberships: a compact header ("Paying fans up 75% in 12 weeks"), the week's paying fans as one large number with its change on the week before, and a band of three sub-figures (joined, left and net) pinned to the foot of the panel. At the end, across a solid divider that meets the top rule, an area chart of twelve weeks with its own scale in thousands and a number under every week. The chart is also the control: a native range input is laid over it, so dragging, touching or pressing the arrow keys moves a guide and a dot from week to week, and the big number (its digits roll), the change and the three sub-figures follow. It opens on the last week, so the hero number and the chart's last point agree. Everything is computed from the weekly joins and leaves, so the text and the drawing can't disagree. On a phone the hero panel comes first and the chart sits under it, below a rule. It's built from Guides, SlidingNumber, Lucide icons and hand-drawn SVG in your theme's foreground colour, with no chart library. For the overview of a membership, subscription or community product, between a hero and pricing.
FAQ
How do I change the numbers?
Edit OPENING, JOINED and LEFT at the top of the file: the fans before the first week, and one reading per week of fans who joined and fans who left. The count for each week, the headline's growth, the scale (whole thousands around the data), the curve, the three sub-figures and the number of week labels are all computed from them. Add a week to both lists and the chart gets another point.
How does dragging the chart work?
A native range input with a value from the first week to the last sits invisibly over the chart, so it brings mouse, touch and keyboard handling for free: arrow keys step one week, Home and End jump to the ends. Its name is "Week" and its value text reads the week, the count and the change aloud, for example "Week 7: 5,632 paying fans, +148 on the week before". The visible guide, the big dot and the highlighted week number are moved by two CSS variables that are set from the chosen week.
How is the chart drawn?
The counts are scaled into a 100 by 100 box and turned into a smooth path that never overshoots a reading. The box stretches to its cell (preserveAspectRatio="none" with a non-scaling stroke), while the gridlines, scale labels, dots and week numbers are HTML placed from the same numbers, so they stay crisp. The scale starts below the lowest week rather than at zero and says so with its labels. The chart box is dir="ltr" because time runs the same way in every language.
Is it accessible?
Yes. The chart is an image named with its span and its first and last readings, and the same facts are available as text through the range input, which is a real, named, keyboard-operable control with a visible focus outline. The hero number and its change sit in a polite live region, so a screen reader hears the new week as you move. The sub-figures are a description list; the minus is a true minus sign, and the signs are kept left to right so a right-to-left page doesn't move them.
Why does the sub-figure band end the block?
The band is the last thing in the hero panel, so it has no bottom rule and the panel has no bottom padding: the next section's top rule is its foot. The divider between the panels runs from the top rule down to the same line, with a + where it meets the rule. On a phone the divider becomes a rule between the two parts.
What moves, and what does reduced motion change?
The header and the chart fade up once on load, the area fades in, and the guide and the big dot glide between weeks in 200 milliseconds. The digits of the number roll to each new week. With reduced motion all of it is off: the guide jumps and the digits change in place. Nothing scrolls sideways at 320 pixels.
Related
- 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
Area Chart With Pill Tabs Stats
Area and lineA framed area chart for a traffic analytics tool with pill tabs for Day, Week, Month and Year: choosing one swaps the readings, the labels under the chart and the total, whose digits roll.
- Pro
Annotated Area Chart Stats
Area and lineA framed area chart of checkout latency with three numbered pins, two deploys and an incident, tied to an ordered list of notes under it; hovering or focusing either one lights the other.
- 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
Split Subvalues Hero Metric Stats
Hero metricA parcel carrier's weekly total in display type at the start of a split, with its three service levels as rows at the end, each with its count and a share bar, so the shares add up to exactly 100%.
- Pro
Connected KPI Bar Stats
KPI bands and tilesFour headline figures for a subscription analytics tool in cells that share their hairlines from rail to rail, each with its change on the month before and a tiny sparkline of the last twelve months.