Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Sortable Sparkline Tile Grid Stats Block for React

Six web-vitals tiles in one hairline frame, each with a fourteen-day line, its low and high marked by ticks, and a Sort by switch that re-orders them by change, budget used or volatility.

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 sparkline tile grid for React with Base UI. A start-aligned header has a Sort by switch (Change, Budget used, Volatility) at its end and a line under the sentence that says how the tiles are ordered. Under it, six tiles share their hairlines inside one frame with + marks on its corners: each shows a web vital (largest paint, interaction delay, layout shift, server response, first paint and blocking time), its latest value, its change since day one, a fourteen-day line with ticks at its low and high and a dot on the last day, and one line that says what the current sort measures for that tile ("84% of its 2.5 s budget"). Switching the sort re-orders the tiles, biggest first, and announces the new order; the grid never changes shape. Three across from lg, two across below it. For performance, operations and finance pages that want the reader to pick what to chase first.

FAQ

How do I change the vitals or the sorts?

Edit VITALS and SORTS at the top of the file. A vital is a label, a budget, its decimals, a unit and fourteen daily readings (oldest first). Change is the move since day one as a share of day one, budget used is today's reading over the budget, and volatility is the gap between the lowest and highest reading as a share of the average. Add a sort by adding an entry to SORTS, a number to Figure and a branch to orderedBy.

How does the sort switch work?

It is the catalog's Segment Group, a single-choice control with arrow-key movement, wired to one piece of state. The list itself is re-ordered, not just restyled, so reading order and focus order follow what you see. A polite live region under the header announces the new order once.

What are the ticks on each line?

The line always runs between 10% and 90% of its box, so the lowest and highest readings sit at fixed heights; two short ticks at the start edge mark them, and the line under the tile gives the two numbers in words ("Low 1.9 s, high 2.9 s"). The dot is the last day.

Why aren't good and bad coloured?

Lower is better for most vitals and higher is better for others, so the block shows direction with an arrow and a sign and leaves the judgement to the reader. The only thing that tells a tile it is over budget is its text ("101% of its 800 ms budget").

Is it accessible?

The tiles are an ordered list and each is a description list; every line is an image with a text name that gives its start, end, lowest day and highest day. The switch has an accessible name and visible focus. Values sit in bdi elements and signed changes stay left to right for right-to-left pages.

How does it fit on a phone?

The switch takes the full width under the header and the tiles sit two across. Re-ordering moves tiles between slots, so the page's height does not change.

  • Pro

    Sparkline Stats

    Sparklines

    Three sparkline cells for a web-analytics tool, each with its figure for the last seven days, its change on the seven before and thirty days of line under a soft fade.

  • Pro

    Sparkline Tile Grid Stats

    KPI bands and tiles

    Four KPI tiles for a subscription-box company, each holding the same twelve weeks as an area sparkline, with one slider that moves a cursor through all four and rewrites their values to the chosen week.

  • Pro

    Six measures of a stationery shop as aligned sparkline rows in one framed panel on a shared month axis, with a guide that reads all six at the month under your pointer.

  • Pro

    Compact KPI Tile Grid Stats

    KPI bands and tiles

    Six 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

    Seven rows, one per weekday, each a strip of 24 hourly squares scaled to that day's own peak, with its total and its peak hour, in cells whose lines run past their corners.

  • Pro

    Three ratings metrics for an app-store tracker in cells that share their hairlines, each with a twelve-week line filled beneath it when it climbs and above it when it falls.