Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Vertical KPI Rail Stats Block for React

A 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.

Framework
UI library

Preview

Preview width

Installation

Part of Pro
Pro unlocks the code and one-line install of every Pro button and text effect, plus the MCP for your AI editor.
Have Pro already? Sign in to open it.Opens here as soon as you're Pro.

Overview

A vertical KPI rail for React with Base UI. The block is a split between solid rails. At the start, the header states the headline number, "On-time delivery reached 94.1% in week 12", with a sentence and, pinned to the foot on large screens, the week the figures report and what they are compared with. Past a hairline divider that runs up to the top rule, four figures (parcels in transit, on-time rate, customs hold and cost per kilogram) are stacked in a narrow rail. Each row shows the value large, its label under it and the change on the week before as an arrow and a signed number, in your theme's foreground colour: no green for good, no red for bad. Every figure, change and the headline's number are computed from one typed set of weekly readings. On a phone the rail follows the header and the rows are the same. For a logistics, operations or reporting page where four numbers sit beside the story that explains them.

FAQ

How do I change the figures?

Edit WEEKS and KPIS at the top of the file. Each KPI is a label, a series of weekly readings (oldest first, one per week), a write function that formats a reading and a change kind: count for a difference (+11), percent for a share of the week before (−0.7%) or points for rates (+0.7 pts). The row's value, its change and the headline's number are all read from the series, and the week names carry no year, so nothing goes stale.

How do I change the rail's width or its side?

The rail is the second column of a two-column grid, lg:grid-cols-[minmax(0,1fr)_24rem]: change 24rem to resize it. To put the rail at the start, give it lg:col-start-1 lg:row-start-1 and move the divider (lg:border-s) to the header's cell, keeping the header first in the DOM so the reading order stays the same.

Why aren't rises green and falls red?

Whether a change is good depends on the figure: fewer parcels held at customs is good news, fewer on time isn't. The block shows the direction with an arrow and the sign, and leaves the judgement to the reader. That also keeps it correct in every theme preset and readable without colour. Dashes mark no change.

Is the KPI rail accessible?

Yes. The figures are a description list: each label is a term, and the value and the change are its descriptions. The value is drawn first but read after its label, so a screen reader hears "On-time rate, 94.1%, +0.7 pts vs week 11". The arrows are hidden from assistive technology because the sign says the same, the minus is a true minus sign, and values sit in bdi elements with signs kept left to right for right-to-left pages.

Why does the divider run to the top rule?

The column is the grid itself, with the padding on its cells, so the rail's start line meets the page's top rule at a + mark, the way the other split blocks do. On a phone the divider is a hairline between the header and the rail, with its own marks. The rail ends the block, so it draws no bottom rule: the next block's top rule closes it.

What happens on a phone?

The header comes first, then the rail with the same four rows. The line that names the week and its comparison is hidden on phones, since the headline and every row already say it ("in week 12", "vs week 11"). Nothing scrolls sideways at 320 pixels.

  • Pro

    Connected KPI Bar Stats

    KPI bands and tiles

    Four 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

    Minimal KPI Bar Stats

    KPI bands and tiles

    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.

  • Pro

    Icon KPI Tile Grid Stats

    KPI bands and tiles

    Four linked KPI tiles for a home-services marketplace, each an icon plate, a value, a label and an Open report line, in a hairline frame beside a split divider.

  • Pro

    Four support-desk figures in the four quadrants of a crosshair, with a hairline cross at the centre where a round badge names the quarter, each with its value and its change on the quarter before.

  • Pro

    A 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

    Reverse Split News List Hero

    Updates and timelines

    A reverse split hero on drafting lines for a team docs workspace: a greyscale product illustration beside an announcement pill, the headline, a ruled list of the latest updates as links, a Shine Button and a second action.