SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Can’t find it? Contact us

RankedList

A numbered list of things ranked by a figure, such as the most read posts, the top pages or a leaderboard.

View code
tsx
<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.

Terminal
npm add @sdxc/ui remix
typescript
import "@sdxc/ui/theme.css";

Or copy it into your project to edit it:

Terminal
sdxc ui add ranked-list

Usage

typescript
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.

  • RankedList
  • RankedList.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 an href; 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

tsx
<RankedList numbered={false}>…</RankedList>

Props

Read from the component's own types, so every prop, every default and every allowed value is listed.

PropTypeDefaultRequiredDescription
numberedboolean—NoDraws 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">.

@sdxc/ui

Can’t find it? Contact us