Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Minimal Hero Metric Stats Block for React

One number and nothing else for a food-bank tool: the week's meals served in display type under the page's top rule, one hairline and one sentence that compares it with last week and last year.

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 minimal hero metric for React with Base UI. One number in display type ("14,820", up to 96 pixels tall) rolls up once the block scrolls into view, then a single hairline and one sentence under it: "meals served this week across 41 partner pantries, 340 more than last week and 1,120 more than the same week last year". There is no card, no control and no chart, only the page's top rule and that hairline, so it is the lightest block in the stats family and sits well between two heavier sections. The number and the sentence are one h2, so the heading reads as a whole sentence. The comparisons are computed from three typed weekly counts. The rolling digits start as zeros of the finished number's width, so nothing moves. It's built from SlidingNumber and Guides.

FAQ

How do I change the number?

Edit MEALS (this week, last week and the same week a year ago) and PANTRIES at the top of the file. The sentence is computed: it says "more" or "fewer" from the sign of each difference and writes the amounts with thousands separators. Change the words around the number ("meals served this week") for your own metric.

Why is the number part of the heading?

So the heading says the whole thing. A screen reader landing on it by heading hears "14,820 meals served this week across 41 partner pantries, 340 more than last week and ...", instead of a bare number in one place and a loose sentence in another. The rolling digits are hidden from assistive technology; it reads the final value, never the digits in between.

How does the roll-up behave, and is it motion safe?

It starts the first time the number is at least a quarter in view: each digit rolls from zero to its place with a short CSS transition. The digits start as zeros of the finished number's width (14,820 starts as 00,000), so the centred number never shifts while it rolls. With reduced motion the digits change in place with no roll. Swap in the catalog's CountingNumber for a ticker that races through every value instead.

Does it work in right-to-left languages?

Yes. The block is centred, the numbers sit in bdi elements so digits and separators keep their order, and the hairline and the type are symmetric.

How does it fit on a phone?

The number drops to 60 pixels (a size at each breakpoint from there up) and the sentence wraps in a narrower measure under the same hairline. Nothing scrolls sideways at 320 pixels.

  • Pro

    One headline figure for a treasury tool, cash on hand in a big number inside a card in a card, with a change pill, a comparison and a two-line footnote that says when it was read and from where.

  • Pro

    A parcel carrier's weekly total in display type at the start of a split, with its three service levels as rows at the end, each with its count and a share bar, so the shares add up to exactly 100%.

  • 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

    Animated Counter Hero

    Stats and live data

    A compact centered hero for an invoicing app with an announcement pill, a Shine Button and a second action, over a hairline band of four figures that count up when they scroll into view.

  • Pro

    A giant static member count for a loyalty platform under a centred header with two buttons, then a band of three secondary figures and a closing strip of eight customer wordmarks.

  • Pro

    A centred card-in-card hiring CTA whose Shine Button wears a pinned count of open roles, with three featured roles as links in one hairline-divided strip below it.