[data-reveal]{opacity:1!important;transform:none!important}
Top list
Components

Top list

A ranked leaderboard card — rows with a value, a delta, a bar and an optional sparkline.

TopListCard lists rows in rank order: an optional rank badge, an icon or avatar, a title and a description, a formatted value, an optional delta and an optional row sparkline. The top rows can be highlighted, rows can link elsewhere, and an empty list shows emptyLabel.

Top listTopListCard
Connecting to the DMS preview…
ConnectingDMS 0.9.59 options set

Usage

src/pages/sales.ts
import { TopListCard } from "@antelopejs/interface-dms/base/top-list-card";

static products = TopListCard({
  title: "$shop.sales.top_products",
  fetchUrl: "/api/sales/top-products",
  periodScope: "sales",
  valueFormat: "currency",
  currencyCode: "EUR",
  showRank: true,
  highlightTopN: 3,
});

The route answers { items: TopListItem[] }. An item carries an id, a title and a value, plus optional description, valueLabel, delta (in percent), sparkline, icon, avatar (src, alt) and to.

Options

Options of the Top list block
OptionTypeDefaultDescription
title*Contentstring–Card heading.
descriptionContentstring–
emptyLabelContentstring–
valueFormatAppearance"number" | "currency" | "percent" | "compact"–
currencyCodeAppearancestring–
valueSuffixAppearancestring–Text after each value, such as " ms" (with its leading space).
showRankAppearanceboolean–
highlightTopNAppearancenumber–How many leading rows to highlight.
rankColorAppearancestring–
showDeltaAppearanceboolean–
showBarAppearanceboolean–
showSparklineAppearanceboolean–
sparklineAccentAppearancestring–
badgeColorAppearancestring–
maxHeightAppearancestring–
invertBehaviorboolean–

valuePrecision is available in code (Value precision).

Recipes

A unit after each value

valueSuffix: " ms" with valuePrecision: 0 turns 1864 into "1,864 ms". The suffix is written as given, so the space goes in it; a $ key is translated. A row whose figure no format can write sends a valueLabel instead — a string, a $ key or a composed text — which replaces the value and its suffix while value still sizes the bar.

Rows that keep the reader's scope

A row's to may carry {{params.X}} / {{query.X}}, filled from the page URL when the row is drawn. A route answering to: "/modules/shop/products?id=42&store={{query.store}}" keeps the reader's store without knowing it.

Pitfalls

  • skeletonCount defaults to 10 loading rows; set it to the usual number of rows to keep the card's height.
  • A row's title and description take $ keys or composed texts; never format numbers into them on the server.

Next steps

Activity feed

Events over time instead of a ranking.

Chart card

The trend next to the ranking.