shadcn.io is not affiliated with official shadcn/ui
Delta Pill KPI Tiles Stats Block for React
Four raised KPI tiles for a checkout analytics tool, each with its change as a pill: filled for a rise, outlined for a fall and muted for none, with an arrow or a dash and a sign.
Installation
Overview
Delta pill KPI tiles for React with Base UI. A centred header states the headline number, "Orders are up 9.1% on the 28 days before". Under it four tiles sit apart, each raised as a card inside a hairline frame whose lines run a little past its corners. A tile shows the value (it rolls up once), its label and its change as a pill with "vs the 28 days before" next to it. The pill tells rise, fall and no change apart by shape, never by colour: a filled pill with an up arrow for a rise, an outlined pill with a down arrow for a fall and a muted pill with a dash for no change, each with its sign. Every value, change and the headline are computed from one typed set of readings, and the average order is revenue divided by orders. Four across from lg, two by two from sm; on a phone the tiles are a row that scrolls sideways and snaps. For a store, analytics or finance overview.
FAQ
How do I change the figures?
Edit the readings at the top of the file (ORDERS, REVENUE, CONVERSION, REFUNDS): each is a { before, now } pair for the last 28 days and the 28 days before. KPIS says how each is shown: its label, its prefix, suffix and decimals, and whether its change is a percent of the period before (+9.1%) or a difference in points (+0.23 pts). The average order is computed from revenue and orders. The pill's direction comes from the sign of the change, and a change that rounds to zero is shown as no change.
How are the pills told apart without colour?
By fill and by glyph. A rise is a pill filled with the text colour, with white (background-coloured) text and an up arrow; a fall is an outlined pill with a down arrow; no change is a muted pill with a dash. All three carry the sign, and the arrow is hidden from assistive technology because the sign says the same. The pill colours come from your theme's foreground and background, so it works in every preset and in print.
Is it accessible?
Yes. Each tile is a description list: the label is a term, and the value and the change are its descriptions, so a screen reader hears "Orders, 6,420, +9.1% vs the 28 days before". The minus is a true minus sign. Values sit in bdi elements and signed changes are kept left to right for right-to-left pages. On a phone the row of tiles can be reached and scrolled with the keyboard: it takes focus, has a label and shows a focus ring.
How are the frames drawn?
Each tile is a list item with its own Guides component: lines that run a little past the corners, which is why the tiles keep a gap-6 between them and the grid is inset from the rails. The card inside it is bg-card with a faint ring and a small shadow, so it reads as raised in light and dark themes alike.
How does the carousel work on a phone?
Below sm the list is a flex row with scroll snapping: each tile takes 85% of the width and snaps to the centre, so the next one peeks in. The list has vertical padding, so the frames' overshoot isn't cut off by the scroller. From sm it is a grid and the tiles show all at once.
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
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
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
Renewal Delta Callout Stats
ComparisonsA subscription renewal comparison that leads with the percent change at display size, then the month before and this month as two tiles.
- Pro
Pill Trend Sparkline Stats
SparklinesThree delivery measures as rail-to-rail rows, each with a wide twelve-week line whose change on the week before is a pill pinned to the end of the line, level with the last point.
- Pro
Metric Cards Bento Logos
BentosSix customer results for an invoice-financing product in two bands of cells, each with the customer's wordmark, a figure at display size, what it counts and a chip with the change since last year.