Card List

Card List

HkCardList is the standard hairline list: an unpadded card whose body is a role="list" column of rows separated by hairlines. Each row is an HkListRow — an optional tone-tinted icon chip, a main column (title, subtitle, free-form content) and a trailing lane for badges, switches or controls. It exists because that anatomy had been copy-pasted across ten console views before it became a component: a bordered surface, rows at px-4 py-3 with a 12px gutter and a hairline between them.

  • When the records are a grid — columns with widths, sorting, selection, bulk actions — use HkTable; a list row has no columns and no header.
  • When the rows need an editor and a per-row validation line, use HkEditableTable.
  • A list of records with an icon, a title and a trailing status is exactly this component's job; for a titled section that contains such a list, put it in a HkSectionCard.

Import

tsx
1
import { HkCardList, HkListRow, type HkListRowAction, type HkListRowActionsMode } from "@celestia-island/hikari";
rust
1
2
use hikari_components::*;          // CardList, ListRow, MdiIcon, StatTone
use hikari_components::prelude::*; // CardListProps, ListRowProps, rsx!, VNode

The Rust form is two plain functions, CardList(CardListProps { … }) and ListRow(ListRowProps { … }). CardList wraps its children in a Card with padded: false, exactly like Vue; the difference is how it decides whether there are rows at all, which is the subject of the second section.

Rows: icon, title, subtitle and the trailing lane

HkListRow is the row shape: icon (rendered as an HkIconChip), iconTone (primary by default, the HkStatCard palette), title, subtitle, the default slot for anything else in the main column, and a trailing slot pinned to the right edge for badges, switches or a small button. Every piece is optional — a row with only a title is legitimate, and a row with only a default slot is the free-form case.

The row is a list item, not a button. Set clickable when the whole row drills through: that adds tabindex="0", the hk-list-row-clickable class (cursor, focus and hover contract) and a click emit that fires on a pointer click and on Enter / Space while the row itself is focused — keys bubbling from a focusable child are left alone. In the Vue form, clicks inside the trailing lane stop at their wrapper, so a switch or a delete button in that lane owns its press and never double-fires the row's drill-through; the Rust mirror wraps the lane too (div.hk-list-row-trailing, styled in the card list sheet), but that wrapper carries no click stopper: a trailing press still bubbles to the row handler and would fire the drill-through as well, where the Vue form stops it at the wrapper. ListRow records the same split.

edge-proxy
eu-west-1 · 3 replicas
healthy
billing-db
eu-central-1 · primary
synced
audit-archive
us-east-1 · read-only replica

The glyphs differ on purpose: the Vue side has the whole lucide set (Server, Database), while MdiIcon is a fixed enum with no database or shield glyph, so the nearest published stand-ins are used (CubeOutline, Package, Layers) — the same list, three different pictograms. Two structural notes for the mirror. First, has_rows is an explicit flag: a Rust Element is always present, so the "did the default slot render anything?" probe Vue runs cannot exist — pass has_rows: true whenever you pass rows, or the list renders the empty branch. Second, the mirror's ListRow requires children (it has no default), and empty_vnode() — the prelude's empty text node — is how the empty default slot is written (rsx! {} has neither an element nor a braced expression, and the macro rejects it with Expected element, braced expression, or control flow); trailing is a Some(rsx! { … }) slot which this sample leaves out, which is why the Rust card shows no badges while the TSX card does.

The empty state, and what counts as "no rows"

The empty branch is the point Vue's prop has no equivalent for: the component inspects the default slot's rendered vnodes, not the slot function, and treats a comment placeholder, an empty children array, or a fragment of false entries as nothing rendered. That is what makes the canonical idiom work — <HkListRow v-for="row in rows"> over an empty array plus v-if rows both read as empty, so the list collapses to the empty lane instead of showing an empty bordered card.

The empty slot replaces the whole list surface (no role="list" wrapper, no hairlines); with no empty slot and no rows, the body is simply empty inside the card. The list is inside an unpadded card either way, so an empty-state lane supplies its own inset.

total is the scroll-progress denominator: it is forwarded to the nearest enclosing enabled HkScrollProgressDock, and omitting it makes the dock count the delivered DOM rows — right for a fully delivered list, and drifting low for a windowed one.

No servers yet

Register a host to see it here.

The TSX card starts empty and shows the empty lane; deleting the last row of a populated list would flip it back to the same lane without any host-side v-if. The Rust card is the same branch, driven by has_rows: false — and its children is omitted entirely, which the mirror's CardList does not need (only ListRow requires children).

Row actions: the overlay lane and the touch menu

actions turns a row into a record with named commands. On a pointer device the array renders as an inline lane of icon buttons, each named by its name (that string is the button's accessible name and its tooltip), danger paints it destructively and disabled refuses a press; the lane is wrapped in a role="toolbar" named by actionsLabel and revealed on hover / focus-within — it costs the row no width while hidden. actionsMode: "persistent" moves the lane into the flow so it stays visible.

On a touch-first client (hover: none or pointer: coarse) the same actions array becomes a single ⋯ trigger that opens an HkMenu popup, because tooltips never fire there. That switch is automatic; actionsMenuLabel names the trigger and the menu title (falling back to actionsLabel). A tap inside the row reveals the overlay lane; a tap anywhere else dismisses it.

Every action needs a name. It is the key the menu selection maps back with, so two actions with the same name are the same entry — keep them unique per row.

Disk usage above 90%
eval on every 5 minutes
Certificate expires in 7 days
checked nightly
email

The action lane is Vue-only. The mirror carries the row shell, the icon chip, the title / subtitle / default slot and the trailing slot — but not actions / actionsMode / actionsLabel / actionsMenuLabel, so a Rust list that needs per-row commands renders them inside trailing or the default slot and owns the click handling (and the touch menu) itself. If the commands have to behave identically on both faces, a Rust host is better served by HkTable's manageable column, which the mirror does carry.

HkCardList's own Vue prop list is short — total only. The rest of the Vue API this page describes lives on HkListRow (its props, its click emit and its slots), which the generated table above does not cover: it is generated for the page's component.vue / component.rust names, and the row is a second export.

API

Vue

Props

NameTypeDefaultRequired
totalNumberundefined—

Rust

Props — CardList

PropTypeDefaultDescription
has_rowsboolfalseWhether the default slot actually rendered any row (Vue probes the vnode array; see the header delta).
emptyOption<Element>NoneThe empty slot: rendered INSTEAD of the list surface when has_rows is false (Vue: the empty slot).
childrenElement(empty)—

Accessibility

  • The row list is a real role="list" whose children are role="listitem"s, so a screen reader announces the item count. The icon chip is decorative by contract (aria-hidden), so the row's meaning has to live in its title / subtitle text — do not put the only label in the chip.
  • A clickable row is <div role="listitem" tabindex="0"> with an Enter / Space handler: it is reachable and activatable, but it is not a link or a button, so it announces as a list item with no role of its own — a drill-through that must announce as navigation should wrap a <button> or <a> inside the row's main content instead. In the Vue form, keys pressed on a focusable child (a switch, a lane button) are left to that child; the mirror's key handler has no such target check, so an Enter on a focused control inside a clickable Rust row also runs the row's onclick.
  • The pointer action lane is a role="toolbar" named by actionsLabel, with one named button per action; without actionsLabel the toolbar is unnamed. The touch form is a single aria-haspopup="menu" trigger whose aria-expanded follows the popup.
  • Clicks inside the trailing lane and the action lane are stopped at their wrappers, so a button in those lanes never triggers the row's drill-through — including the click a keyboard Enter synthesizes.
  • total is only a progress denominator; it is not announced by the list itself, and the dock's pill is the surface that reports progress.

Related components

  • HkTable — the column grid, when the records need widths, sorting, selection or bulk row actions.
  • HkEditableTable — the editable grid for inline editing with validation.
  • HkSectionCard — the titled section that frames a list with a heading, a hint and a footer note.
  • HkScrollProgressDock — the pill total feeds, which counts rows for a long list.
  • HkEmptyState — the standard empty lane this list's empty slot usually renders.