Skip to main content
Clever Ops

Stats Composition Bar

Part-to-whole React stat band, one Tailwind-token stacked bar splits into hairline-seamed segments with a legend ledger of preformatted shares beneath it.

Preview & code

Loading Stats Composition Bar preview

Installation

pnpm dlx shadcn@latest add @cleverui/stats-composition-bar

Requires the @cleverui registry in your components.json, a one-off, two-line setup.

Usage

tsx
import { StatsCompositionBar } from '@/components/blocks/stats-composition-bar'
Exampletsx
import { StatsCompositionBar } from '@/components/blocks/stats-composition-bar'

export default function StatsCompositionBarDemo() {
  return (
    <div className="mx-auto max-w-6xl">
      <StatsCompositionBar
        heading="Revenue by product line"
        footnote="FY26 recognized revenue, unaudited"
        segments={[
          {
            label: 'Platform seats',
            value: '$2.4M · 46%',
            share: 46,
          },
          {
            label: 'Usage overages',
            value: '$1.3M · 25%',
            share: 25,
          },
          {
            label: 'Professional services',
            value: '$890K · 17%',
            share: 17,
          },
          {
            label: 'Marketplace apps',
            value: '$420K · 8%',
            share: 8,
          },
          {
            label: 'Training & certs',
            value: '$210K · 4%',
            share: 4,
          },
        ]}
      />
    </div>
  )
}

API reference

StatsCompositionBar accepts the following props.

PropTypeDefaultDescription
headingstring'Revenue by product line'
segments*StatsCompositionBarSegment[]2–5 parts in descending order
footnotestringmono methodology line
headingLevelnumber2heading element level

…plus everything from React.HTMLAttributes<HTMLElement>: className, event handlers, aria attributes and the rest pass straight through.

Referenced types

Typestsx
export interface StatsCompositionBarSegment {
  label: string
  /** preformatted display, e.g. '$2.4M · 46%' */
  value: string
  /** percent width; normalized if sum ≠ 100 */
  share: number
}

Frequently asked questions

How do I install the Stats Composition Bar component?

Register the @cleverui registry in your components.json ("@cleverui": "https://cleverops.com.au/r/{name}.json"), then run `npx shadcn@latest add @cleverui/stats-composition-bar`. The shadcn CLI copies the source into your project, you own the code from that point. You can also copy the source directly from this page.

What dependencies does Stats Composition Bar require?

Stats Composition Bar uses motion on top of React and Tailwind CSS. You don't need to install it manually, the shadcn CLI resolves and installs npm dependencies automatically when you add the component.

Can I theme Stats Composition Bar to match my brand?

Yes. The component is styled entirely with Tailwind utilities over standard design tokens (primary, background, muted, border), so it inherits your existing shadcn/ui theme automatically. Change your CSS variables and the component follows, no source edits needed for palette, radius, or fonts.

Want this built for you?

CleverUI is built by the Clever Ops web team. If you'd rather ship a hand-coded, fast, custom website than assemble one, we build them for Australian businesses every week.

Explore web development services