shadcn.io is not affiliated with official shadcn/ui
Animated Counter Hero Block for React
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.
Installation
Overview
Impress visitors with metrics that count up as they come into view, in a compact centered hero for React with Base UI. The section sits on the page's drafting lines: two rails at the edges of the page column that continue into the blocks above and below, a rule along its top edge that runs to the page's edges, and a plus mark on each crossing. Inside, an announcement pill links to a milestone, a two-line headline sells Ledgerline, an invoicing app for freelancers, and a primary ShineButton and an outline Button, both links, sit over a small free-plan line. A band between the rails closes the hero: four cells of one hairline grid, each led by a figure built with CountingNumber that races off and slows into its value, with a label and a one-line description under it: freelancers with a plus, money paid out to one decimal with a currency sign and an M, uptime to two decimals and countries. It's built from Guides, Announcement, Status, Shine Button, Button and Counting Number with Tailwind CSS, and the entrance is CSS that stays still under reduced motion. Made for SaaS landing pages, company pages, investor-facing pages and any product page where a few big numbers make the case.
FAQ
How do I change the figures and their labels?
Edit the COUNTERS array at the top of the file. Each counter has a value, the decimals it always shows (1 for 4.2, 2 for 99.98), a prefix and a suffix written around the number ($, +, M, %), a duration in milliseconds, a label and a one-line description. CountingNumber writes the thousands separators itself through its grouping prop, in a fixed en-US locale so the server and the browser agree; pass locale to write the numbers another way. Keep four cells: the band is a four-column grid from md and a two-by-two below it.
When do the numbers count, and what happens with reduced motion?
Each number counts once, from 0, when a quarter of it has scrolled into view (trigger="view"), racing off and slowing into its value over its own duration. Before that, and while the page loads, it shows 0. With reduced motion turned on, every number shows its value at once and nothing counts; with scripts off, the values show as plain text. The rest of the hero fades up once on load with CSS transitions, which reduced motion also turns off.
How are the lines and plus marks drawn?
They are the Guides component, an aria-hidden layer that draws the lines of the box it sits in. The page column (max-w-6xl, the same in every block) has Guides bleed marks="top" rules="top": two side rails that run the section's full height, so they join the rails of the blocks above and below, and one rule along the top edge that runs to the page's edges (the section's overflow-x-clip stops it there), with a plus on each crossing. The block below draws the next rule, so a stack of blocks never doubles a line. Inside, the figures are a grid gap-px bg-border of bg-background cells with a border-y, so the cells share one hairline between them, and the band's two top and bottom corners get a plus from <Guides marks="corners" rules="none" sides={false} />, which lands them on the rails. Every line is solid and is the theme's border colour, so it follows any preset.
How do I show live figures from my backend?
Pass the real numbers as each counter's value, fetched wherever your page loads its data. A CountingNumber that gets a new value counts on from the number it's showing, not from 0, so a figure that updates while the page is open ticks up to the new total. Keep the decimals, prefix and suffix in your data next to the value, so 99.98% never shows as 99.98 or loses its sign.
How do screen readers read the counters?
The counters are a description list: each figure is read with its label and its description, and always as its final value (Freelancers, 48,000+), never as the numbers flying past during the count. The headline is the block's one h1, and the pill and both calls to action are links named by their text.
How does the hero adapt to phones and tablets?
The band sits in two columns on phones and four from the md breakpoint, and its numbers step up from text-2xl to text-3xl at 360px, text-4xl at sm and text-5xl at lg. A number never wraps, and its digits are tabular, so they don't jostle while they count. The headline wraps, balanced, the two calls to action sit side by side or wrap onto a second line, and both are on the first screen of a phone, with the figures right under them.
Related
- Pro
Counter Stats Hero
Stats and live dataA compact, start-aligned hero for an email API on solid rails: a headline, a Shine Button and an outline button, then four counters in separate cells whose hairlines overshoot their corners.
- Pro
Metric Tiles Hero
Stats and live dataA compact left-aligned hero for an edge network with a live status pill, a Shine Button and an outline button at the end of the row, and four metric tiles below, each a ruled cell with a trend.
- Pro
Left-Aligned Social Proof Bar Hero
Logos and social proofA compact start-aligned hero closed by a three-cell social proof bar on its own rule: an avatar stack with the user count, a five-star rating with the review count and a compliance mark.
- Pro
Centered Progress Bar Hero
Updates and timelinesA compact centered launch hero with a full-width progress bar that fills on load, four milestone cells divided at the quarter marks, the Shine Button and a second action.
- Pro
Split Integration Flow Hero
Diagrams and mapsA split hero for a metrics pipeline: the headline and a Shine Button beside a divider and a flow diagram in a hairline frame, with a closing band of three proof cells.
- Pro
Centered Activity Feed Hero
Stats and live dataA split hero with a live pill, a headline and two actions beside a ruled feed of recent activity, each row with an avatar, a name, an action and how long ago.