Bar list
Ranked rows, each with a name, a bar to a shared scale and a formatted value: top pages, top referrers, busiest endpoints. Rows can be links or buttons, and a long list folds behind “Show all”. For values over time, use the bar chart.
Install
npx shadcn@latest add @thrum-pro/bar-listThis is a Pro component. The command works once your project has a licence key: set up Pro or see pricing.
Data shape
type BarListItem = {
key?: string; // default: name
name: string;
value: number | null; // null = no data, sorted last
href?: string; // the row becomes a link
};[
{ name: "/pricing", value: 8420 },
{ name: "/docs/install", value: 6115 },
{ name: "/blog", value: 2390 },
{ name: "/changelog", value: null },
]Props
| Prop | Type | Default | Description |
|---|---|---|---|
data | readonly BarListItem[] | Required | The rows, in any order. |
label | string | Required | What the list ranks. Names the list for screen readers. |
sort | "descending" | "ascending" | "none" | Default "descending" | Order of the rows by value. none keeps the order of data. Missing values always go last; equal values keep their order. |
max | number | – | Rows shown before a “Show all” button. Leave out to show every row. |
format | Intl.NumberFormatOptions | Default compact | How values are written. |
locale | string | Default "en-US" | Locale for number formatting. |
color | string | Default var(--chart-1) | Any CSS colour for the bars. |
onSelect | (item: BarListItem) => void | – | Makes every row without an href a button, called with the picked row. |
sound | boolean | Default true | Play a soft click when a row button is picked, if the visitor has sound on. Links are silent. |
emptyLabel | string | Default "No data" | Text shown when there are no rows. |
className | string | – | Merged onto the root. It fills the width it is given. |
Motion and sound
Motion
- First draw: each bar grows from zero in 250 ms. Bars start 40 ms apart, and the whole entrance takes 550 ms at most however many rows there are.
- New values: each bar moves to its new length in 400 ms with no overshoot. Rows that “Show all” reveals appear at their length.
- Reduced motion: every bar appears at its length at once.
Sound
- A soft click when a row button is picked. Links and “Show all” are silent.
Sound is off until the visitor turns it on. Pass sound={false} to keep this component silent. How sound works
Accessibility
- The rows are a list named by the label, so a screen reader announces how many rows there are and reads each name with its value.
- Bars are hidden from screen readers: the value is in the text. A long name is cut with an ellipsis and its full text is the row's title.
- “Show all” is a button with aria-expanded that controls the list. Its text says how many rows there are.
- Rows that are links or buttons are 36 px tall and show the focus ring. It is a list, not a chart, so it has no reading cursor.
| Keys | Action |
|---|---|
| Tab | Move to the next row link or button, then to “Show all”. Plain rows are not tab stops. |
| Enter | Follow the link, or pick the row. |
| Space | Pick the row, or show or fold the rest of the list. |
Source
The source comes with Pro
TypeScript source · Copy-paste ready · MIT-compatible for client projects · Includes all dependencies
Files and dependencies
- Adds
components/ui/bar-list.tsx- Packages
motion- Brings along
- Chart foundationsMotion tokensSound engineButton
Changelog
- 1.0.0 · 2026-12-03First release.