Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Dual Stat Metric Banner Block for React

A two-figure metric banner for a store dashboard: two cells split by a hairline, each with a label, a big figure, its change on last week, a thin bar to the weekly goal and that share in words.

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 two-figure metric banner for React with Base UI, for a dashboard that wants two numbers side by side and nothing else. Two cells share the column between the page's solid rails, split by a hairline that runs up to the top rule with a + mark where they meet; on a phone the cells stack with a rule between them. Each cell holds a label, a big figure, an arrow with its change on last week, a thin bar filled to the share of the weekly goal, and that share in words. The bars are your theme's foreground; only a falling change carries the destructive colour, and only on its arrow. It's built from Guides and Progress, with your theme's tokens for every colour. For weekly digests, store and sales summaries, A/B result strips and any header that compares two figures at a glance.

FAQ

How do I change the two figures?

Edit METRICS at the top of the file: each entry has a label, the figure as text, the change on last week as a number (a positive one points up, a negative one down), the share of the goal reached and the goal as text. The share is typed, not computed from the figure, because the figure is already formatted ("$38.4k"); keep the two in step when you change one.

Why is only the falling change coloured?

A rise is the normal case and a fall is the exception, so colour is spent on the exception. The arrow for a fall uses the destructive colour; the number itself stays in the foreground colour, which keeps the text readable in every theme and means the change reads the same without colour, through the sign, the arrow's direction and the words "on last week". The bars never take a status colour, because nothing here has crossed a limit.

Is the bar read out to screen readers?

The bar is a picture of the sentence under it, so it is hidden from assistive technology and the words carry the information: "64% of the week's 6,700 goal". Each figure and its change are plain text, with the percentage and amounts in bdi elements so a right-to-left layout keeps the signs and units in order. The + and the real minus sign are part of the text, so the change is read as a number with a sign.

How does it look on a phone?

Below md the cells stack, one under the other, with a full-width rule and + marks between them instead of the vertical hairline. The figure and its change wrap onto two lines if they need to, and nothing scrolls sideways at 320 pixels.

Can I add a third figure?

Add an entry to METRICS and change md:grid-cols-2 to md:grid-cols-3. Every cell after the first draws its own hairline and + mark, so the divider follows on its own. Past three the figures get narrow; for a row of many, a stats block fits better.

  • Pro

    A one-figure metric banner for a product-analytics tool: a capacity ring in a framed figure, a big figure that rolls up from zero, the limit, this week's change and a link.

  • Pro

    A revenue banner for a sales dashboard, as a card in card: the figure, a change badge and the comparison at the start, a 24 h and 7 d switch and a bar sparkline at the end, swapping in place.

  • Pro

    An API-quota banner for an API platform on a tinted band: a bar with 80% and 95% ticks, the warning colour past the alert, and a hatched stretch to 100% for where the pace leads.

  • Pro

    A storage-quota banner for a cloud-storage service: a heading and an Upgrade button over a stacked bar split by type, with four legend cells on shared hairlines naming each type and its size.

  • Pro

    Card Inset Metric Row CTA

    Figures and stats

    A start-aligned card-in-card CTA for an API platform: a headline, one sentence and two calls to action, with three platform figures in a closing band across the foot of the panel.

  • Pro

    A results table of five customers with a before, an after and the change between them, whose column headers sort it, in a band between the rails: a split divider sets the quote of whoever is at the top of the table apart from the table, with + marks where it meets the band's rule.