Components
Ranked List
Card-wrapped ranked leaderboard with truncated labels, tabular values and an optional share-of-leader bar behind each row.
Ranked List
A card with a title, optional description and a ranked list of label and value rows. By default each row has a bar behind it, sized as a share of the top value. When items is empty, the card shows emptyNote instead of the list.
Installation
Terminal
$npx shadcn@latest add @vandoko/ranked-listUsage
import { RankedList } from "@/components/ranked-list";
const items = [
{ label: "Organic search", value: 4210 },
{ label: "Paid social", value: 2875 },
{ label: "Referral", value: 1120 },
];
export default function Page() {
return <RankedList title="Top channels" description="Sessions, last 30 days" items={items} />;
}Props
| Prop | Type | Default | Description |
|---|---|---|---|
title | string | — | Card title |
description | string | — | Text under the title |
items | { label: string; value: number }[] | — | Rows, in the order to show them |
valueFormatter | (n: number) => string | n.toLocaleString() | Formats each value |
showShareBar | boolean | true | Bar behind each row, sized against the leader |
emptyNote | string | — | Shown when items is empty |
className | string | — | Extra classes on the card |