Values side by side as labelled bars: top products, traffic sources, storage by type.
$ pnpm dlx shadcn@latest add https://dashral.com/r/bar-list.jsonInstallation
$ pnpm dlx shadcn@latest add https://dashral.com/r/bar-list.jsonAdds the component, the components it builds on, its npm packages and the theme tokens it uses. Using Dashral often? Add the registry to components.json once:
{
"registries": {
"@dashral": "https://dashral.com/r/{name}.json"
}
}Then add components by name:
$ pnpm dlx shadcn@latest add @dashral/bar-listUsage
import { BarList } from "@/components/dashral/bar-list"
<BarList
items={[
{ label: "/pricing", value: 1240 },
{ label: "/docs", value: 860 },
{ label: "/blog", value: 410 },
]}
showShare
aria-label="Page views by page"
/>Examples
Links and shares
href makes a label a link; showShare adds each value's share of total; hint adds muted text.
API reference
BarList
Also takes every prop of <ul>(opens in a new tab).
| Prop | Type | Default |
|---|---|---|
items | { label, value, icon?, hint?, meta?, display?, href?, color?, key? }[]The rows. display replaces the formatted value; color is any CSS color for that bar. Required. | — |
color | "primary" | "neutral" | "info" | "success" | "warning" | "destructive" | "highlight"The bars' color. | "primary" |
showRank | booleanNumbers the rows (an ordered list). | false |
showShare | booleanEach value's share of total, as a percentage. | false |
total | numberWhat shares are of: pass it for a top N of more. | the values added up |
max | numberThe value a full bar stands for. | the largest value |
locale / formatOptions | string / Intl.NumberFormatOptionsHow values are written. | "en-US" |
linkAs | ElementTypeYour router's link for rows with href, e.g. Next.js Link. | "a" |
classNames | { item, icon, label, value, track, bar }Classes for each part. | — |
className | stringExtra classes, merged with cn() so yours win. | — |
Accessibility
- A list (ordered with showRank); every value, and its share, is written out as text, so the bars are hidden from assistive technology.
- Give it an aria-label that says what's measured.
Motion
- Rows rise in and bars grow from the left, one after another (--duration-considered). Instant with reduced motion.