Dashral Pro is on the wayGet 30% off at launch

Dashral

Bar List

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.json
  1. House Espresso Blend53 sold$2,014
  2. Hand Grinder10 sold$790
  3. AeroPress19 sold$741
  4. Gayo Arabica, 250 g48 sold$672
  5. Kintamani Natural, 250 g44 sold$660

Installation

$ pnpm dlx shadcn@latest add https://dashral.com/r/bar-list.json

Adds 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:

components.json
{
  "registries": {
    "@dashral": "https://dashral.com/r/{name}.json"
  }
}

Then add components by name:

$ pnpm dlx shadcn@latest add @dashral/bar-list

Usage

example.tsx
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

Icons and colors

icon before each label, and a color per bar.

  • Archives343.1 GB
  • Videos182 GB
  • Documents11.1 GB
  • Images4.6 GB

Links and shares

href makes a label a link; showShare adds each value's share of total; hint adds muted text.

Top by revenue

One card, three rankings behind tabs: products with units sold, countries with flags and shares, devices.

Top by revenue

  • Retro 35mm Film Camera212 sold$48,200
  • Mechanical Keyboard145 sold$31,650
  • Pour-over Coffee Set354 sold$22,810
  • Linen Desk Mat241 sold$9,400
  • Brass Desk Lamp51 sold$6,120

API reference

BarList

Also takes every prop of <ul>(opens in a new tab).

PropTypeDefault
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"
showRankboolean

Numbers the rows (an ordered list).

false
showShareboolean

Each value's share of total, as a percentage.

false
totalnumber

What shares are of: pass it for a top N of more.

the values added up
maxnumber

The value a full bar stands for.

the largest value
locale / formatOptionsstring / Intl.NumberFormatOptions

How values are written.

"en-US"
linkAsElementType

Your router's link for rows with href, e.g. Next.js Link.

"a"
classNames{ item, icon, label, value, track, bar }

Classes for each part.

—
classNamestring

Extra 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.