Skip to content

Stat Bars

Percentage bars that grow, one after another, when the chart scrolls into view.

From the Nitip template — see it in context

94%

Projects delivered on time

78%

Clients who come back

62%

Traffic from organic search

Installation

$ npx shadcn@latest add https://framebrick.co/r/stat-bars.json

Usage

import { StatBars } from "@/components/ui/stat-bars";

<StatBars stats={[{ value: 94, label: "Projects delivered on time" }, { value: 78, label: "Clients who come back" }]} />

Props

PropTypeDefaultDescription
stats{ value: number; label: string }[]—Values are percentages (0–100).
heightnumber320Height of the chart from 640 px up, in px.
classNamestring—Classes for the row.
  • Bars start at 30% and grow 50 ms apart — Nitip's refinement over Framer, kept here.
  • Below 640 px the bars lie flat and their width follows the value.
  • They grow once, the first time they are seen.
  • With reduced motion the bars appear at their value instead of growing.

AI prompt

Paste into v0, Lovable, Bolt or Claude to rebuild this component in your own project.

Create a React + Tailwind CSS + Motion (motion/react) component called StatBars.
- A row of bars, one per stat: bg-primary, text-primary-foreground, rounded-md, p-4, the value as a large
  tabular-nums percentage at the top, a hairline under it, and the label at the bottom.
- Each bar's height is its value in percent of the chart height, and its opacity follows the value
  (minimum 0.35 so small bars stay readable).
- Animate a CSS variable --fill from 30% to the value with whileInView (viewport once, amount 0.5) and a spring
  (bounce 0.2, duration 0.4s), delayed by 50ms per bar, with the bar's height reading height: var(--fill).
- Under 640px the bars stack as horizontal rows whose width is the value instead.
- With prefers-reduced-motion (useReducedMotion), start the bars at their value and use no transition — a CSS
  variable is not a transform, so MotionConfig would not skip it.

Be the first to know

Get new templates and components first

One short email when we release a template or a free component. No spam — unsubscribe anytime.

We use your email only for Framebrick updates. Privacy policy