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-list

Usage

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

PropTypeDefaultDescription
titlestring—Card title
descriptionstring—Text under the title
items{ label: string; value: number }[]—Rows, in the order to show them
valueFormatter(n: number) => stringn.toLocaleString()Formats each value
showShareBarbooleantrueBar behind each row, sized against the leader
emptyNotestring—Shown when items is empty
classNamestring—Extra classes on the card

On this page