ListRow
A full-width row in a list: a label, content before it and a value at the far end.
Overview
A short list where each row opens something, toggles a section or holds its own buttons.
List
import { Card, ListRow } from "@hackcove/ui";
<Card flush>
<ListRow trailing="R 9 500">Rent</ListRow>
<ListRow divided trailing="R 1 850">
Transport
</ListRow>
<ListRow divided href="#bills" trailing="3">
Bills
</ListRow>
</Card>Card flush, and divided draws the line between them on every row after the first.import { Card, ListRow } from "@hackcove/ui";
<Card>
<ListRow trailing="R 9 500">Rent</ListRow>
<ListRow divided trailing="R 1 850">
Transport
</ListRow>
</Card>flush sit inside its padding, so the hover fill stops short of the edges and the lines do not run across.Row actions
import { Button, Card, ListRow } from "@hackcove/ui";
<Card flush>
<ListRow
static
actions={
<>
<Button size="sm" variant="outline">
Reject
</Button>
<Button size="sm">Accept</Button>
</>
}
>
Grace Hopper
</ListRow>
</Card>static, and the buttons go in actions.import { Button, Card, ListRow } from "@hackcove/ui";
<Card flush>
<ListRow href="#grace" trailing={<Button size="sm">Accept</Button>}>
Grace Hopper
</ListRow>
</Card>Usage
- Put the rows in a
Card flushand setdividedon every row after the first.trailingis a value, a count or aPill;leadingis anAvataror an icon. - A row with
onClickis a button; withhref(orrender, for a router's link) it is a link.externalopens a link in a new tab. expandedmakes the row the header of a collapsible section: you own the state and the section, and passaria-controlsto name it.selectedmarks the one row whose detail is open; set it on a single row of a list.- A row that holds its own buttons is
static: the buttons go inactions, aftertrailing.revealOnHovershows them only on hover or focus, so a long list is not a wall of buttons. - Never put a button or a link inside a button or link row.
size="sm"is the dense padding for a list that must fit more rows. - Records with several columns to compare are a
Table, not rows.
Accessibility
- A button row is a native
<button type="button">; a link row is a real link; astaticrow is a plain<div>with no click target. selectedsetsaria-current="true"on the row.expandedsetsaria-expandedand draws a chevron, which is hidden from assistive tech.- A button or link row has a focus ring from the component;
disabledfades the row and stops pointer events. revealOnHoveractions appear when the row is hovered or has focus inside it, so a keyboard user can reach them, and they are always shown on a touch screen.
API
ListRow
A full-width row that is a <button> (or, with href or render, a link) with a hover fill, a left-aligned label and trailing content at the far end. With expanded it is the header of a collapsible section: aria-expanded and a chevron. Rows sit in a Card flush; divided draws the line between them, on each row after the first. leading is content before the label, and selected marks the row in view. static makes the row a plain <div> for one that holds its own buttons (a button cannot sit inside a button or a link): actions follow trailing, and revealOnHover shows them only on hover or focus.
actionsButtons for this row, after trailing: Button size="sm", IconButton.
- Type
ReactNode
dividedA hairline above the row: set it on every row after the first.
- Type
boolean
expandedMakes the row a collapsible header: sets aria-expanded and shows a chevron that turns down
when open. The caller owns the state and the section; pass aria-controls to name it.
- Type
boolean
externalOpens in a new tab: adds target="_blank" and rel="noreferrer".
- Type
boolean
href- Type
string
leadingContent before the label: an Avatar, a thumbnail, an icon.
- Type
ReactNode
render- Type
LinkRender
revealOnHoverHides actions until the row is hovered or something in it has focus, so a long list is not a
wall of buttons. A touch screen has no hover, so they are always shown there.
- Type
boolean
selectedMarks the row in view, the one whose detail is open: a violet fill and aria-current="true".
Set it on one row of a list.
- Type
boolean
sizesm is dense padding. Defaults to md.
- Type
"sm" | "md"
staticA row that is neither a button nor a link, for one that holds its own controls: a <div> with
no click target and no hover fill (unless revealOnHover), taking actions as well.
- Type
true
trailingContent at the far end of the row: a value, a count, a Pill.
- Type
ReactNode