Stats, bars


Install
npx shadcn add @klarhimmel/stats-barsDetailsAbout, usage, props and more
Two to six measures as labelled horizontal bars with the value at the end.
Import
Import
- stats/bars
- About
- Two to six measures as labelled horizontal bars with the value at the end. The bar length is the number in `value` (0 to 100, any step: 4% draws 4%; the old `fill` prop is ignored); use it for shares and rates, not for raw counts.
- Category
- A few numbers that prove the point. New project? Set it up once: /get-started/installation.
Notes
When to use it
Two to six measures as labelled horizontal bars, for shares and rates such as satisfaction or uptime. Use stats-rings for a few percentages as circles, and stats-row for raw counts.
Writing for it
- The first number in value (20 characters) is the bar length from 0 to 100, so write '62%' or '4,5 %'. A value of '4.5' draws a bar of 4.5 percent. - Use the 100 character note under a bar to say how the number was measured, for instance the period and the sample. - Put the labels in a consistent order, such as largest first, because the bars are stacked with the same width and compare by eye.
Watch out for
A value with no number in it, like 'High', draws no bar at all, only the text. The old fill prop is ignored, so setting it does nothing.
Pairs well with
Usage
The block in a page, with its default content (long lists shortened). Every prop is in the table below.
Props
The type, default and text limit of every prop. On a real page, over-limit text is kept and checkSections flags it (Installation, Check a page before you ship); this live preview shows the default until it fits. The panel above edits all props.
| Prop | Type | Default | Description |
|---|---|---|---|
eyebrow | string | 'Name the section' | Text, up to 60 characters. |
title | string | 'Say what the shares divide' | Text, up to 120 characters. |
description | string | 'Say what the shares are of and acro…' | Text, up to 300 characters. |
items | { label, value, note }[] | 4 items | List of 2 to 6. Each item: label, value, note. |
headingLevel | '1' | '2' | - | One of '1', '2'. Optional; empty is not rendered. |