shadcn.io is not affiliated with official shadcn/ui
Minimal KPI Bar Stats Block for React
Four figures for a bookkeeping tool in cells that share their hairlines from rail to rail, each only a label and a value, under a one-line header that names the period.
Installation
Overview
A minimal KPI bar for React with Base UI. A one-line header, "Where your invoices stand", names the period and the count at its end, and under it four figures (invoiced, paid, overdue and days to get paid) sit in cells that share their hairlines, in a band that runs from rail to rail and ends the block. Each cell holds a label and a value and nothing else: no change, no icon, no chart, no chrome beyond the lines and the + marks where the band meets the rails. The values count up once when they scroll into view. Every figure is added up from one typed list of invoices, so invoiced, paid and overdue always agree and "days to get paid" is the real average. Four cells sit in a row from lg and two by two below it. For a finance or admin page that needs four numbers at the top and nothing to read around them.
FAQ
How do I change the figures?
Edit the INVOICES list at the top of the file: each invoice has an amount, the day of the window it was issued and due, and the day it was paid (or null while it is open). Invoiced is the sum of all of them, paid the sum of the paid ones, overdue the open ones whose due day is behind today (WINDOW), and days to get paid the average wait between sending and payment, rounded to whole days. Nothing is typed twice, so the four cells can't disagree. The window is counted in days, never dated, so the copy doesn't go stale.
How does the count-up work, and what if motion is off?
Each value is the catalog's Counting Number, which counts up once when its cell scrolls into view. With reduced motion, or with scripting off, it shows the final value at once, and screen readers always read the final value, never the numbers in between. The tabular figures keep the cell from shifting while it counts.
Why no change arrows or sparklines?
This is the bar for a page that wants the numbers and no commentary. If you want the change on the period before, use the connected KPI bar; if you want a trend in each cell, use the trends variant. Adding a line to a cell here means one more dd in the list.
Is the minimal KPI bar accessible?
Yes. The figures are a description list: each label is a term and its value the description. Values sit in bdi elements and the dollar sign is kept left to right, so a right-to-left page doesn't move the currency. The header is a real heading, and the cells have no colour to rely on.
Why is there no line under the figures?
The band ends the block. On a page, the next section draws its own top rule along the band's foot, so a bottom border here would double it, and the column has no bottom padding for the same reason. The band's top rule comes from the Guides component. If nothing follows the block, add a bottom border to the list's wrapper.
How does it fit on a phone?
Below lg the four cells sit two by two, meeting at a hairline cross, with smaller values. Each cell lays its label and value on two rows it shares with the cell beside it (a CSS subgrid), so when "Days to get paid" wraps, the values in that row still line up. Nothing scrolls sideways at 320 pixels.
Related
- 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.
- 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.
- Pro
Vertical KPI Rail Stats
KPI bands and tilesA split for a shipment tracker: the headline and the week at the start, and past a hairline divider four figures stacked in a narrow rail, each with its change on the week before.
- Pro
Compact KPI Tile Grid Stats
KPI bands and tilesSix dense KPI tiles for a café group in one hairline frame, with a Day, Week and Month switch that re-reads all six figures and rolls their digits.
- Pro
Minimal Hero Metric Stats
Hero metricOne number and nothing else for a food-bank tool: the week's meals served in display type under the page's top rule, one hairline and one sentence that compares it with last week and last year.
- 72%Pro
An export job in one row for an invoicing tool: a thin progress bar with its percentage and seconds left that fills once and turns into a Download button, with Cancel and Run again.