RankedList
A numbered list of things ranked by a figure, such as the most read posts, the top pages or a leaderboard.
View code
<RankedList aria-label="Most read this month">
{posts.map((post) => (
<RankedList.Item>
<RankedList.Label href={post.href}>{post.title}</RankedList.Label>
<RankedList.Value>{post.views}</RankedList.Value>
</RankedList.Item>
))}
</RankedList>Installation
An ordinary dependency: install it, import the theme once, and import the component where it is used.
npm add @sdxc/ui remiximport "@sdxc/ui/theme.css";Or copy it into your project to edit it:
sdxc ui add ranked-listUsage
import { RankedList } from "@sdxc/ui";Renders the list: an <ol> of RankedList.Items with the markers drawn by each row,
so the rank, label and figure line up in columns. Restyle the rows through
RankedList.CustomProperties on the list.
Composition
The parts the component publishes, each a static property of the host.
RankedListRankedList.ItemOne row: its rank from the list's counter in muted tabular numerals, then the RankedList.Label and the RankedList.Value at the end, in whichever order they are written.RankedList.LabelWhat is ranked, a link to it when given anhref; it wraps onto as many lines as it needs beside the figure, never pushing it out of the row.RankedList.ValueThe figure the row is ranked by, held to the row's end on one line in muted tabular numerals, so figures of one magnitude line up down the list.
Examples
<RankedList numbered={false}>…</RankedList>Props
Read from the component's own types, so every prop, every default and every allowed value is listed.
| Prop | Type | Default | Required | Description |
|---|---|---|---|---|
numbered | boolean | — | No | Draws each row's rank before its label; false keeps the order and drops the numbers. |
Also accepts everything in TagProps<"ol">.
RankedList.Item
Also accepts everything in TagProps<"li">.
RankedList.Label
RankedList.Value
Also accepts everything in TagProps<"span">.