RankList
The v3 ranked list (Home's "Top creators this month", a drawer's "Top creators for this product"): a RankMedal (1–3 gold, silver, bronze), the lead cell and the value, optionally a ShareBar against the leader. An ordered list, so the rank is also the reading order. onSelect makes each row a button (→ the creator drawer).
import { RankList } from '@ergasti/bricks';Examples
Top creators
Ranked rows with a bar behind each, sized by amount against max. Rows open when you give onSelect.
Code
import { CreatorCell, Money, RankList } from '@ergasti/bricks';
import { blocksData } from './sample-data';
function Top() {
const top = [...blocksData.MINE].sort((a, b) => Number(b.sales) - Number(a.sales)).slice(0, 5);
return (
<div style={{ maxWidth: 480 }}>
<RankList
label="Top creators this month"
max={Number(top[0].sales)}
onSelect={() => {}}
items={top.map((c) => ({
id: c.id,
lead: <CreatorCell id={c.id} name={c.name} identity={{ handle: null, invitedByYou: false, links: null, avatarUrl: blocksData.photo(c.id) }} tier={c.tier} />,
value: <Money value={c.sales} compact />,
amount: Number(c.sales),
}))}
/>
</div>
);
}Nobody to rank yet
RankList draws the rows it is given and nothing more, so check items.length and show an empty line instead (here the kit's ListState).
Code
import { ListState, RankList } from '@ergasti/bricks';
function Empty() {
const items: { id: number; lead: string; value: string; amount: number }[] = [];
return (
<div style={{ maxWidth: 480 }}>
{items.length ? <RankList label="Top creators this month" items={items} /> : <ListState loading={false} error={null} empty emptyText="No sales this month yet, so there is no ranking." onRetry={() => {}} />}
</div>
);
}Props
Prop
Type
Design guidance
How the BRICKS design system uses RankList. Written in docs/content/components/RankList.md; the props above are read from the code, which wins where the two disagree.
A short ranked list: medal, a person or product cell, and the figure, optionally with a "vs #1" bar; use it for "Top creators this month" and other top-N cards.
RankList is the v3 ranked list. Each row is a soft rounded tile with a RankMedal (1–3 gold, silver, bronze; the rank is the list position), your lead cell (usually CreatorCell), and the value at the end. With max on the list and amount on an item it adds a ShareBar under the value. It is an ordered list, so rank is also the reading order; onSelect makes each row a button that opens the creator.
Anatomy
- List (
ol.kit-ranklist,aria-label): 8px gap. - Row (
.kit-ranklist-row, abutton.clickwithonSelect): flex, 12px gap, 12px 16px, 16px radius,--soft. - Medal:
RankMedal rank={i + 1}. - Lead (
.kit-ranklist-lead): grows,min-width: 0. - Value (
.kit-ranklist-v): boldvalue, and aShareBar(min 110px; 84px on phones) whenmaxandamountare set.
Variants
| Prop | Value | Look | When |
|---|---|---|---|
max + item amount | set | Value with a "vs #1" bar under it | Product drawer "Top creators for this product" |
max | omitted | Value only | Home "Top creators this month" |
onSelect | set | Rows are buttons (hover --color-surface-hover) | Rows open the creator drawer |
States
| State | Trigger | Look |
|---|---|---|
| Static | no onSelect | div rows |
| Hover / focus-visible | button rows | Hover surface; --focus-ring |
| Empty | items=[] | Empty list (show your own empty text) |
| Phone | narrow | Lead sub lines wrap |
Types
RankItem: id (required), lead (required node), value (required node), amount (number, for the bar).
Usage
Home › Top creators this month:
<Card>
<Card.Header title="Top creators this month" actions={<ButtonLink size="sm" href="#creators">See all</ButtonLink>} />
<RankList label="Top creators this month" onSelect={(id) => openCreator(id)} items={top.slice(0, 4).map((c) => ({
id: c.id,
lead: <CreatorCell id={c.id} name={c.name} identity={c.identity} sub={<><TierChip tier={c.tier} /> · {`${c.orders} orders`}</>} />,
value: <Money value={c.sales} compact />,
}))} />
</Card>With bars against the leader:
<RankList label="Top creators for this product" max={Number(top[0].sales)}
items={top.map((c) => ({ id: c.id, lead: <CreatorCell id={c.id} name={c.name} identity={c.identity} />, value: <Money value={c.sales} compact />, amount: Number(c.sales) }))} />Where it appears
- Brand › Home › Top creators this month (4 rows, opens the creator).
- Brand › Motivation › challenge drawer › Top creators.
- Brand › Analytics › product drawer › top creators.
- Screens: Home, Motivation, Analytics.
Guidelines
Do
- Keep it to 3–5 rows with a "See all" link to the full table.
- Pass items already sorted by the server.
Don't
- Don't use it for long lists; use
DataTablewith a rank column.
RTL and Arabic
- Rows mirror (medal at the right in Arabic); the bar fills from the inline start.
Tokens
--soft, --ink, --color-surface-hover, --focus-ring, plus RankMedal and ShareBar tokens.
Accessibility
- An
<ol>named bylabel; each medal reads "Rank N". - Button rows: Tab, Enter/Space.
Found in the source
- ARIA attributes set:
aria-label. - Its tests cover: “with onSelect each row is a button: click and Enter open that id”.
Read from the component's source and tests. See Accessibility for the patterns the library follows.
Related
RankMedal,ShareBar: its parts.Leaderboard: the PR challenge leaderboard with a winners cut.HBars: comparison by item.
See also: CreatorCell · Money · ListState · Accordion · Card · HeroCard · KeyValue
Source
src/kit/patterns/RankList.tsx (line 22) on GitHub.