Bar List

View as Markdown

Ranked rows, such as top pages, each with a bar as long as its share of the largest.

Top pages

Visitors by country

  • Germany9,12038%
  • United States8,80636%
  • Brazil3,41014%
  • Japan2,2709.4%
  • Egypt6402.6%

When to use

Ranked rows, such as top pages, each with a bar as long as its share of the largest. Use Bar Chart instead when the values need an axis to read.

Usage

import { BarList } from "./ui/uicontext/components/BarList.ts"
export const Pages = <M>(h: Html.H<M>) =>	BarList(h, { label: "Top pages", items: [{ id: "/", label: "/", value: 18420 }, { id: "/pricing", label: "/pricing", value: 6210 }] })

Examples

Money

format writes each value; a value at or below zero draws no bar.

  • Enterprise$412.0K
  • Business$286.4K
  • Team$98.3K
  • Starter$12.9K
  • Legacy (refunds)-$1.8K

API reference

Options

BarList options
NameTypeDescription
labelrequiredstringWhat's ranked: "Top pages".
itemsrequiredBarListItem<Message>[]The rows, in any order: the largest goes first.
format(value: number) => stringWrites a value, such as "$1.2K" or "38%". Plain numbers in the reader's format otherwise.
sharebooleanShows each row's share of the total after its value.
headingsreadonly [string, string]Column headings over the rows: ["Page", "Views"].
sortedbooleanKeeps the given order instead of putting the largest first.
limitnumberDraws only this many rows.
localestring—
styleStyle—

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/bar-list

Source