shadcn.io is not affiliated with official shadcn/ui
Donut Center Readout Stats Block for React
An ad-spend donut whose middle follows your choice: it shows the total until you press a channel, then that channel's spend and share while its arc lifts out of the ring.
Installation
Overview
A donut with a selection-driven centre for React with Base UI. A start-aligned header ("Search and social took 64% of ad spend") sits over a card in a card: a muted shell with a + on each corner round a raised panel. In the panel, a donut of the last 28 days' ad spend in five solid foreground weights (from twelve o'clock, clockwise, largest channel first, a 2 px gap between neighbours), and the five channels as a list of buttons at its end. By default the middle shows the total spend. Press a channel and its arc lifts out of the ring (it grows thicker) while the middle shows the channel's name, its spend (the digits roll) and its share; press it again and the middle goes back to the total. The shares are whole numbers that add up to 100. The donut is at the start of the panel and the list at its end from lg; on a phone the donut comes first. It's built from Guides and SlidingNumber, with SVG circles for the ring and plain buttons for the choice, so it is identical on every library.
FAQ
How do I change the channels?
Edit CHANNELS at the top of the file: each has an id, a label and the spend. Up to five weights are defined in WEIGHTS. The total, the shares, the arcs, the rows and the header's headline are all computed from the list; nothing else needs editing.
How does the selection work?
Each row is a native button with aria-pressed. One channel can be pressed at a time: pressing another moves the lift and the middle to it, and pressing the pressed one again clears the choice, so the middle shows the total. Tab moves between the rows and Space or Enter presses one. The state is plain React state (picked), so you can also drive it from elsewhere.
Is it accessible?
The rows are real buttons in a list, named by their text, and the pressed one has a foreground bar on its start edge as well as a tint, so it never relies on colour alone. The donut is hidden from assistive technology since the list says the same, and a polite status line says what the middle shows after each press ("Social: $12,760, 26% of spend").
Related
- Pro
Donut Breakdown Stats
Parts of a wholeA budgeting app's month of spending as a framed donut with its total rolling up in the middle, beside a legend of five buckets with amount and share, the shares adding up to exactly 100%.
- Pro
Donut Pill Legend Stats
Parts of a wholeA traffic-source donut over a row of pill toggles: switch a source off and its arc leaves the ring, the others grow to fill it, and the shares and the total in the middle are worked out again.
- Pro
Donut With Callouts Stats
Parts of a wholeA city's electricity mix as a framed donut with four callouts standing round it at twelve, three, six and nine o'clock, each joined to its arc by a thin leader line; on a phone, a two by two grid.
- Pro
Two-Ring Donut Stats
Parts of a wholeA headcount donut with two rings: the departments' groups inside and their teams outside, each team sitting in its own group's arc, with a nested legend whose shares add up at every level.
- Pro
Half Donut Card Stats
Parts of a wholeA team's weekly capacity as a 180-degree arc of four segments with the total in its foot and a four-cell legend band, with no needle: one whole, shared out.
- Pro
Score Bar Leaderboard Stats
LeaderboardsSeven quiz players in a band that runs from rail to rail, each row a name, a context line, the points and a thin bar measured against the leader's score.