Skip to content
English

How it works

Every row is a three-column grid: a track holding the bar with the label on top of it, the share and the value. The bar is a light tint of the series colour, so the label stays in ink and readable over it, and a long label simply runs past the end of a short bar. Bar widths are a custom property transitioned on the reveal curve: they grow from zero after the first frame with a 45ms stagger, and switching data remounts the list so the new ranking grows in. Hovering or focusing a row deepens its bar and slides in its share of the total. With limit, a quiet button shows the remaining rows.

Use it for

  • Top-N breakdowns in analytics: pages, referrers, countries, devices, search terms.
  • Any ranking where the names are long and should be read in full width.

Look elsewhere when

  • Values over time, or negative values: use a bar or line chart.

Usage

import { BarList } from './BarList.jsx'

export function TopPages({ pages, onOpen }) {
  return (
    <BarList
      label="Top pages"
      items={pages.map((p) => ({ key: p.path, name: p.path, value: p.visitors }))}
      limit={5}
      onSelect={(item) => onOpen(item.key)}
    />
  )
}

Props

PropTypeDefaultWhat it does
items{ key?: string, name: ReactNode, value: number, icon?: ReactNode }[]—Rows. Bars are scaled to the largest value; the share is of the total.
sort'desc' | 'asc' | 'none''desc'Order by value, or keep yours.
limit / labelsnumber / { more(n), less }—Show the first rows and a button for the rest.
tone / color1-8 / string1Series colour for the bars, used as a soft tint.
showShare / formatShare / formatValueboolean / (pct) => string / (v) => stringtrueThe share appears on hover or focus (always on touch screens).
onSelect(item) => void—Makes each row a button.
labelstring'Ranking'Accessible name of the list.

Accessibility

  • The rows are an ordered list with an accessible name; bars are decorative and every row reads its name, share and value as text.
  • With onSelect each row is a button with a visible focus ring; the share appears on focus as well as hover.
  • The more button reports aria-expanded.
  • Reduced motion removes the growth and the share slide; colour changes stay.

Motion

Bars: 760ms on the reveal curve with a 45ms stagger. Share: 160ms fade and 240ms slide. Hover tint: 160ms.

Add it to your project

Copy the prompt into Codex or Claude Code. The agent reads the published source, shows you what it will write and adds the component next to your own.

BarList.jsxbar-list.csstokens.cssREADME.md

Both files install together. The stylesheet reads the design tokens in tokens.css and carries fallbacks, so it also works alone.

Charts
Trilateration comes with Pro. Its preview shows once you unlock it.