Skip to content
GitHub (opens in a new tab)

BarList

A ranked list where each row's value shows as a quiet bar behind its label.

stableMoleculecontracts/barlist.json

Preview

BarList

A ranked list: each row is a label and its value, with a quiet bar behind the label sized against the largest value. Top rows first, Show all for the rest. Put it in a Section or Card.

Master

Top pages by views, five rows first, each row a link.

Top pages

Usage

One measure, one colour. Values show as text on every row, so the bar only has to show the shape of the ranking. Several series or an axis stay BarChart; usage against a limit stays UsageList.

Do's

  • Top items by one measure in a side column or card, like top pages by views or top customers by revenue
  • A short ranking where people read the exact value of each row, and rows may open the item they name
  • A breakdown that is too long or too narrow for an axis chart

Don'ts

  • Several series, an axis, gridlines or a table view — use BarChart
  • Usage against a plan limit, with near-limit warnings — use UsageList
  • Part of a whole for a handful of segments — use PieChart
  • Records with avatars, actions or selection — use ListView
  • Values compared across several columns — use Table or DataTable
<Section title="Top pages">
  <BarList
    label="Top pages by views"
    maxRows={5}
    data={[
      { label: "/pricing", value: 4820, href: "/analytics/pricing" },
      { label: "/docs/install", value: 3110, href: "/analytics/install" },
      { label: "/blog/launch-week", value: 1960 },
    ]}
  />
</Section>

A ranked list: each row shows a label and its value, with a quiet horizontal bar behind the label sized against the largest value or the total. Rows can add an icon, a meta line and the change from last period. Top rows first, with Show all for the rest.

When to use

  • Top items by one measure in a side column or card, like top pages by views or top customers by revenue
  • A short ranking where people read the exact value of each row, and rows may open the item they name
  • A breakdown that is too long or too narrow for an axis chart

When not to use

  • Several series, an axis, gridlines or a table view — use BarChart
  • Usage against a plan limit, with near-limit warnings — use UsageList
  • Part of a whole for a handful of segments — use PieChart
  • Records with avatars, actions or selection — use ListView
  • Values compared across several columns — use Table or DataTable

What an agent reads

import { BarList } from "agentic-ds-kit";
must
  • An ordered list named by label, so the rank and the number of rows are read
  • Each row reads its label and its value as text; the bar is decoration and hidden from screen readers
  • The change Badge says Up, Down or No change in words with the percent, so its tone is never the only signal; media is hidden from screen readers and the meta line is read as text
  • A row with href is one link, reachable with Tab, with a visible focus ring
  • Show all is a kit Button with aria-expanded and aria-controls pointing at the list, and focus stays on it when rows open or close
defaults
  • sort descending
  • scale max
  • label Ranked list
stops if
  • Do not use it for several series or an axis — use BarChart
  • Do not use it for usage against a limit — use UsageList
  • Do not build ranked rows from ListView, Table or loose bars and text — use BarList
  • Do not colour single bars to mean good or bad; it is one measure in one colour. Direction goes in the change Badge from previous
  • Do not put buttons or menus in media or meta; a row's only action is its href link
  • Do not pass negative values; bars start at zero
  • Do not put it in a Card and a Section at once, or draw a box around it yourself. The title comes from a parent Section or Card
  • Do not use raw hex or primitive --color-* ramps

From contracts/barlist.json: must is the a11y requirements, defaults the prop defaults, stops if the doNot rules where the agent asks instead of inventing a cousin.

Props

NameTypeRequiredDefaultNotes
dataarrayYes—One row per item, in any order: sort decides the order shown. An empty array shows a small kit Empty, No data.
sortdescending | ascending | noneNodescendingdescending puts the largest first; none keeps the order of data.
scalemax | totalNomaxmax sizes bars against the largest value. total sizes each bar as its share of the sum of all values and writes the share, like 33.0% of total, at the start of the meta line.
maxRowsnumberNo—Rows shown before Show all. Without it every row shows. Show all appears only when data has more rows than maxRows, and it turns into Show fewer once open.
valueFormatterfunctionNo—(value: number) => string for the value text, like a currency or a percent. Defaults to the chart format: 1,240, 12.4k, 1.2M.
labelstringNoRanked listNames the list for screen readers, like Top pages by views. The visible title comes from a parent Section or Card.
  • Component
    →

    Bar

    Compare magnitudes across categories with vertical or horizontal bars.

  • Component
    →

    UsageList

    A list of usage limits, one a row: the limit's name, how much is used of it, a bar, and a short note.

  • Component
    →

    Pie

    Part-to-whole share for a handful of segments, as a donut or solid pie.

  • Component
    →

    ListView

    A list of records, one row each: primary and optional secondary line, leading avatar or icon, trailing value, badge, actions, or chevron.