Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Pill Trend Sparkline Stats Block for React

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

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 stats band for React with Base UI. A start-aligned header states the headline (orders delivered rose by a number this week), then a band of three rows runs from rail to rail, divided by hairlines and ending the block. A row has a measure and its latest value at the start and a wide twelve-week line beside it. The change on the week before is not a figure next to the value: it is a pill pinned to the end of the line, level with the last point, so the eye reads the line and lands on what it did. The pill is filled for a rise, outlined for a fall and tinted for no change, and each carries its arrow and its sign, so colour tells nothing. The pill's height comes from the same geometry as the line. For operations, logistics and marketing reports where the question is what changed last. On a phone the line sits under the value and the pill stays at its end.

FAQ

How do I change the rows?

Edit MEASURES at the top of the file: a label, twelve weekly readings (oldest first), the decimals to show and a suffix. The value, the percent change on the week before, the line and the pill's height are computed from the list.

How is the pill kept level with the end of the line?

The geometry helper returns where the last point sits as a percent from the top of the box. The dot and the pill are HTML elements positioned at that percent, so they stay level (and the dot stays round) while the line's box stretches. The line stops short of the box's end to leave room for the pill.

How are rise, fall and flat told apart?

By glyph and fill, never by colour: a rise is a filled pill with an up arrow, a fall is an outlined pill with a down arrow, and no change is a muted pill with a dash. The sign is a real plus or minus sign and is kept left to right for right-to-left pages.

Is it accessible?

Each row is a description list and each line is an image with a text name giving its start, end, lowest and highest week. The pill's text reads as "+3.9% on the week before". Values sit in bdi elements. Nothing depends on colour.

What moves, and what happens with reduced motion?

The band fades up and each line draws from the start to the end, with CSS transitions. With reduced motion they are off and the chart simply appears.

How does it fit on a phone?

Below lg each row stacks: the label and value first, then the line at full width with the pill still at its end. The line keeps its height and nothing scrolls sideways at 320 pixels.

  • 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

    Three app cards for a studio, each with a hero audience figure that rolls up, a twelve-week line and two supporting measures with tiny bar series, in cells set apart with overshoot lines.

  • Pro

    Delta Pill KPI Tiles Stats

    KPI bands and tiles

    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.

  • Pro

    A hero figure for a cash-planning tool beside its own 90-day trend: the runway in months at the start, and a wide line with its high, its low and today marked.

  • Pro

    KPI Bar with Trends Stats

    KPI bands and tiles

    Four 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

    Rep Attainment Table Stats

    Goals and progress

    A quota table for a sales team, each rep's attainment bar beside a badge for the change on last week.