Quire UI
Charts10

Bar list

A ranked list with a bar behind each name. Rows can link, filter the page, show their share and how they changed since the period before.

Installation

npx shadcn@latest add @quireui/bar-list

Usage

<BarList
  label="Top pages"
  items={[
    { name: "/", value: 44753, previous: 39120 },
    { name: "/pricing", value: 25985 },
  ]}
  rows={5}
  headings={{ name: "Page", value: "Visitors" }}
/>

Rows are sorted largest first; sort turns that around or keeps your order. Each bar is measured against the largest row and sits behind the name, so the numbers line up in their own column. The bars are a quiet grey by default, so the numbers stay the loudest thing on the row; color tints them.

headings names the columns above the rows, so it is clear whether the number counts visitors, views or something else. With share, the last column is headed "%" unless you name it.

Change since before

Give a row previous and it shows how it changed, with an arrow and a word for screen readers, not colour alone. A row without one shows nothing, rather than a made-up zero.

Long lists

A list longer than 8 rows scrolls in a fixed height, so a list of 40 countries never pushes the page down. Half of the next row peeks out under a frosted edge, and that edge shows only while there is more to scroll to, top or bottom. rows sets how many show; lists side by side with the same rows stay the same height, which suits a row of cards on a dashboard. rows={false} shows every row.

search adds a field above the rows that narrows them by name, and says so when nothing matches. Bars and shares stay measured against the whole list, so a row looks the same found as it did in place.

To let the page grow instead, limit shows the top rows with a button for the rest, which says how many there are. With limit the list does not scroll.

Filtering by a row

With onSelect, rows are buttons that report their name, to filter the page by a source or a page. selected marks the chosen one. share adds each row's part of the total.

Filtered to X

Rows with an href are links instead. With both, the row still filters, and a small link icon after the name opens the href: it shows on hover, on focus, and always on touch screens. In the example above, each source links to its own page.

When the numbers change, like after filtering, each bar glides to its new length, the same way a progress bar fills. Rows that change rank swap places at once, so the list never shuffles around while you read it.

Top sources

Top pages

  • /44,753
  • /pricing25,985
  • /docs/getting-started20,211
  • /blog/shipping-v215,880
  • /changelog10,105
  • /docs/components/chart8,420

The chip beside "Top pages" is yours to build, as above: a small button that clears the filter.

Several lists in one card

Tabs switch what one card lists, like countries or cities, without a card for each.

Locations

Loading and empty

loading holds the rows' places with bars of falling length, so nothing moves when they arrive. With no rows it says so.

No data

Accessibility

The rows are a list named by label. Each reads as its name, its change and its value, like "/pricing, Down 5%, 25,985". With onSelect they are toggle buttons that say whether they are chosen. A row that also has an href is followed by its link, named like "Open /pricing". The search field is named after the list, like "Search: Top pages".

KeyAction
TabMoves through the rows when they are links or buttons, their link icons, or to the list when it scrolls
Arrow keysScroll a list with rows once it has focus
Enter / SpaceOpens the link, or chooses the row

Motion

When the list first scrolls into view its rows arrive one after another, a few milliseconds apart; a list on screen when the page loads stays put. Bars glide to a new length when their numbers change, over 220ms, and not at all with reduced motion. Rows highlight on hover without easing, and the link icon fades in.

Bar list or something else?

  • Parts of one total, like storage by type: a Meter stack.
  • A value over time: a Chart.

API reference

BarList

A ranked list with a bar behind each name, like top pages or sources. Rows can link, filter the page, show their share, and say how they changed since the period before.

Prop

Type

Also takes every <div> attribute. Style it with [data-slot="bar-list"].

On this page