Overview
Reference usage
A semantic list container (<ul role="list">) for a homogeneous collection of records. DataList owns the list element, the list reset, and the empty state; it delegates row chrome (padding, dividers, density) to the row primitive. Each record is rendered through the children snippet, which must render an <li> — StackedListItem is the recommended row.
Reach for DataList when you have a vertical list of like records. For key–value metadata about a single entity use DescriptionList; for tabular rows and columns use Table.
The headings follow Cinder’s group label pattern.
Usage
A list-level density is inherited by every StackedListItem row that does not set its own density prop. The empty snippet renders inside a component-owned <li class="cinder-data-list-empty">, so it needs no inline styling.
Day groups
Pass groupBy to put consecutive rows under a group header: it returns { key, label, detail } for an item, and consecutive items with one key share a header (Today, Monday, Nov 2, with Central time at the right). Each group is a nested list named by its header, so a screen reader announces the day. Pass items already sorted; they are not reordered.
statusColumn keeps the 128px status column for rows that have no status, so titles line up down the whole list. A status word is never cut: one longer than the column wraps onto a second line inside it, with a 12px gap before the title.
A quiet hairline separates the rows of a list, inset to the row's text. The last row of a list, or of a group, draws none, so rows are separated only between each other. Timeline items and Skeleton rows, which also use StackedListItem, draw none.
statusTrack widens that status column for every two-line row in a list when its status words carry a qualifier. For example, a goal's "Running, checking the result" uses statusTrack="12rem" so it remains separate from the row title; omit it to retain Cinder's 128px default.
trailingTrack does the same for the trailing column of two-line rows: a list whose rows carry a figure in trailing (a cost, a count) passes the width of its widest figure (trailingTrack="9rem"), so the track is one width in every row, with a trailing region or without, and the times before it end at one edge. trailingAlign="baseline" holds a figure on the first line's baseline; trailingAlign="line" centers a control in the title's first-line box on desktop. Pass them only at the widths where rows keep their trailing column; omitted, each row sizes the column by its own content.
Rows that change while you watch
Pass insertionAnnouncement to make the list live: a new row, such as a run that starts while the page is open, appears at the top of its group, and the function receives the number of new rows and returns the text (1 new run) that a polite live region speaks and draws as an accent status strip above the first group. Before any row arrives the region takes no space, so the first render announces and draws nothing, and the list holds the reader's place when the strip appears. Rows inserted above the viewport do not move what the reader is looking at: browsers with scroll anchoring already hold the position, and the list scrolls by the difference where they do not. A list scrolled to its top is left alone, so the new row is seen.
Row actions stay in a fixed column
A row's trailing actions sit in a fixed column at the end of the row, so a status badge or other metadata never changes where an action button lands. Put badges with the metadata in the row's content column, as StackedListItem does, and keep the trailing region for the actions alone.
Long values
The list wraps unbroken values (an identifier) anywhere by default, and StackedListItem rows clamp their titles at two lines, so no value widens the list past its frame.
- Alice Chen
- Bob Osei
- Carol Mwangi
When to use
- Rendering a vertical list of like records where each row shares the same layout.
- Pairing with StackedListItem rows for leading/title/description/meta/trailing content.
- Showing a dedicated empty state when the collection has no items.
- Grouping rows under day headers, or announcing rows that arrive while the list is on screen.
- Presenting key-value metadata for a single entity — use description-list instead.
- Rendering tabular data with rows and columns — use table instead.
Examples
Basic data list
A list of homogeneous records. DataList is the semantic `<ul role="list">` container; each row is a StackedListItem with a title and trailing meta. Row chrome (padding, dividers, density) is owned by the row, so content stays compactly aligned instead of stretching to the viewport edges.
Day groups with a shared status column
groupBy puts consecutive rows under a group header that names a nested list, and statusColumn keeps the status column for rows with nothing to report so titles line up.
Empty state fallback
When items is empty, the empty snippet renders inside a component-owned `<li class="cinder-data-list-empty">` — centered, muted padding, no inline styles required.
A row inserted while you watch
insertionAnnouncement makes the list live: a new run appears at the top of its group, a polite live region says "1 new run", and the page does not change size or lose its place.
Props
Name | Type | Default | Description |
|---|---|---|---|
items required | T[] | The records to render. Each is passed to children. | |
key required | (item: T) => string | number | Key extractor for stable DOM reconciliation. Svelte uses this to identify
each row when the list is reordered, filtered, or updated. Without a key,
rows are matched by index and the wrong row instances may receive updated
props, causing O(n) churn and incorrect rendering.
``svelte
<DataList {items} key={(m) => m.id}>
`` | |
density | 'comfortable' | 'condensed' | List-level density inherited by StackedListItem rows that do not set their
own density prop. Omit to let each row use its own default. A per-row
density always overrides this list-level value.
Note: when passing a variable that may be undefined, spread conditionally
because exactOptionalPropertyTypes is enabled:
{...(density ? { density } : {})} | |
statusColumn | boolean | Keep the status column's width for every row that has no status (a workflow, an agent with
nothing to report), so titles line up down the whole list. A row's own statusColumn wins. | |
statusTrack | text | The width of the leading status column in every two-line StackedListItem row in the list (a
CSS length, such as 12rem). Use this only when a list's status words carry a qualifier that
needs more room than Cinder's normal status column; titles remain aligned across the list. | |
trailingTrack | text | The width of the trailing column of every two-line StackedListItem row in the list (a CSS
length, such as 9rem): the width of the widest figure a row carries in trailing (a cost, a
count). The track is then one width in every row, with a trailing region or without, so the
times before it end at one edge. Omit it and each row sizes the track by its own content.
Pass it only at the widths where rows keep their trailing column. | |
trailingAlign | 'center' | 'baseline' | 'line' | Where a two-line row's trailing region sits against the row's lines: center (the default)
centers it on both lines, baseline holds a figure on the first baseline, and line centers
a control within the title's first line. | |
groupBy | (item: T) => DataListGroup | Group consecutive items under a group header, newest group first as the items arrive. Each group is a nested list named by its header, so a screen reader announces the day. Items are not reordered; pass them already sorted. | |
insertionAnnouncement | (count: number) => string | Announce rows inserted while the list is on screen. Called with the number of new rows; the
returned text (1 new run) is spoken politely through a live region that is also drawn as a
status strip above the first group. The first render announces nothing. Rows inserted above
the viewport do not move what the reader is looking at. | |
children required | snippet | Row renderer. MUST render an <li> (the list root is a <ul role="list">).
StackedListItem is the recommended row — it renders an <li> with
leading/title/description/meta/trailing slots. | |
empty | snippet | Rendered when items is empty. The component automatically wraps the
snippet output in <li class="cinder-data-list-empty">.
Do NOT wrap in an <li> yourself — the component provides the <li>
wrapper automatically. Pass only inner content (e.g. a <p>, a <div>,
or plain text). Contrast with children, which must render an <li>. |