Skip to content
Slotted

List

A vertical run of related rows, with named groups, an empty message and a marker the list draws itself.

Installation

The packages are a 0.x beta on npm, and their public API changes between beta releases without deprecation. One line installs the binding and the default theme.

bash
pnpm add @slotted/react @slotted/theme @slotted/themes
tsx
import { List, ListDefaultsProvider, ListEmpty, ListSection } from '@slotted/react';

Variants

variant decides how the rows are told apart. plain, the default, separates them by spacing alone, which suits a short run inside a card. ruled draws a hairline between rows. framed adds a box around the set. separated gives every row a surface of its own and is the only variant that puts a gap between rows.

plain
  • UPS Ground
  • FedEx Express
ruled
  • UPS Ground
  • FedEx Express
framed
  • UPS Ground
  • FedEx Express
separated
  • UPS Ground
  • FedEx Express

Sizes

size sets the room each row gets: sm, md, the default, or lg. It changes the row’s minimum height, padding, gap and type size together, so a dense side panel and a roomy settings page use the same markup.

sm
  • Aisle 4, bin 12
  • Aisle 4, bin 13
md
  • Aisle 4, bin 12
  • Aisle 4, bin 13
lg
  • Aisle 4, bin 12
  • Aisle 4, bin 13

Markers

marker paints the marker column: none, the default, a drawn bullet, or a number. The reading order is a separate decision. In React, ordered renders an ol; in Angular, the directive goes on the ol you write. An ordered list can paint no number and still read in order, and the bullet keeps its shape whatever typeface the reader has.

bullet
  • Lithium batteries ship by ground only
  • Parcels over 30 kg need a two-person lift label
number, ordered
  1. Receive the pallet at dock 3
  2. Scan every carton
  3. Put each carton away by bin

Groups

ListSection in React and li[slListSection] in Angular hold a heading and a nested list of rows. The nested list names itself by the heading through aria-labelledby, so a screen reader that lands inside a group announces which group it is. end in React, or an element marked slListSectionEnd in Angular, stands at the end of the heading line in tabular figures, for a day’s total or a count. The heading is an h3 by default; React sets it with level, Angular uses the heading element you write.

  • Today$4,820.00

    • Contoso Foods
      PO-2291
      $3,150.00
    • Aster Bakery
      PO-2290
      $1,670.00
  • Yesterday$3,115.50

    • Bluefin Market
      PO-2289
      $2,240.50
    • Driftwood Inn
      PO-2288
      $875.00

Sticky group headings

sticky keeps a group’s heading in place while its own rows scroll under it, inside the nearest scroll container. The heading takes the list’s surface and the library’s sticky stack level, so a row scrolling under it is covered rather than showing through. labelVariant="ruled" in React, or variant="ruled" on slListSectionLabel in Angular, draws the name in the text color over a rule instead of the default small muted caption. Scroll the movements to watch each day’s heading hold until the next one replaces it.

  • Monday4 moves

    • Oat flour, 25 kg
      +40
    • Rye flour, 25 kg
      +24
    • Sea salt, 5 kg
      −12
    • Cane sugar, 10 kg
      −30
  • Tuesday4 moves

    • Oat flour, 25 kg
      −18
    • Dried yeast, 500 g
      +60
    • Butter, 10 kg
      −8
    • Sea salt, 5 kg
      +20
  • Wednesday4 moves

    • Rye flour, 25 kg
      −16
    • Cane sugar, 10 kg
      +45
    • Butter, 10 kg
      +12
    • Dried yeast, 500 g
      −22

Inside a padded box

A card body or a dialog already pads its content, so rows that carry their own inline padding stand two insets in from the box edge. inset removes the rows’ inline padding: the names line up with the card heading, and the rules and the hover fill still run edge to edge.

On shift in Reno

  • Amara Nwosu
    Shift lead, receiving
  • Diego Morales
    Picker, aisles 1 to 6
  • Ingrid Holm
    Packer, station 2

Loading

loading writes aria-busy on the list and draws nothing of its own. The rows stay in place with loading set on each, and Skeleton lines stand in for the text at the widths the loaded text takes, so nothing moves when the data arrives. A SkeletonRegion around the list waits 200 milliseconds before drawing and announces the wait once. Refresh carriers starts a 1.5-second load.

Empty

ListEmpty in React and li[slListEmpty] in Angular are the message a list shows when it holds no rows. The message is an li inside the list, so a screen reader announces a list of one item and reads the message, rather than announcing an empty list and nothing else, and the words stay inside the frame of a framed list.

  • No returns waiting

    A return appears here once the customer ships the parcel back.

A page of a larger set

When the list shows one page of a longer result, set position and setSize on each row. They write aria-posinset and aria-setsize, so a screen reader announces the row as 41 of 128 rather than 1 of 3. Leave them out when every row is present. Name the list after the page it shows.

  • SO-1141
    Granite Outfitters
    $612.40
  • SO-1142
    Cobalt Fitness
    $1,208.00
  • SO-1143
    Fernhill School
    $94.75

A list of links inside a nav landmark is a navigation menu. The list writes no landmark itself: the nav and its aria-label belong to the page. current="page" on the row of the page being shown writes aria-current on the row and paints it as current. Choose a section to move the current row.

Selectable rows

The list draws no check of its own. A Checkbox in the row’s start slot is the control a reader operates and the element a screen reader announces, and selected on the row paints the selection. Badge in the end slot carries the row’s count. Pick an order to add it to the pick list.

  • SO-1182
    Contoso Foods
    6 lines
  • SO-1183
    Atlas Freight
    2 lines
  • SO-1184
    Ember Goods
    11 lines
1 of 3 orders on the pick list

Defaults for an application

ListDefaultsProvider in React and provideListDefaults in Angular set variant, size, marker and inset once for every list under them. A value a list sets itself still wins: the first list below reads ruled and sm from the provider, and the second keeps the sm size and states framed.

  • UPS Ground
  • FedEx Express
  • Dock 1, inbound
  • Dock 3, outbound

Accessibility

KeyEffectFocus
Tabmoves to the next focusable element; every control a row holds is in the page tab sequencethe next focusable element
Shift+Tabmoves to the previous focusable element, under the same rulethe previous focusable element
  • A static list has no pattern in the ARIA Authoring Practices, which cover interactive collections such as Listbox and Grid. List follows HTML and the ARIA roles model.
  • role="list" is written on the root and on every nested group. It is not redundant: List draws its own marker, and Safari with VoiceOver drops list semantics when CSS removes the native one. A role written on the element, such as menu or listbox, is kept.
  • A group is an li that holds a heading and a nested list, and the nested list is named by that heading through aria-labelledby. A screen reader that lands inside a group announces which group it is.
  • loading writes aria-busy on the list, which ARIA 1.2 asks of a container whose content has not arrived. List draws no spinner and no placeholder; Skeleton goes inside the rows.
  • The empty message is an li inside the list. Outside the list, a screen reader announces a list of zero items and reads nothing more, and the words fall outside the frame of a framed list.
  • List binds no key. Every control a row holds is in the page tab sequence, so Tab and Shift+Tab move between them. Arrow keys, Home, End and typeahead belong to Listbox and Table.
  • List holds no state a consumer can own, so it emits no event. A row paints a selection with selected, and the Checkbox composed into the row announces it.

API

List

Props

variant'plain' | 'ruled' | 'framed' | 'separated'Default plain
How the rows are told apart: by spacing, by a rule between them, by a box around the list, or by a surface for each row.
size'sm' | 'md' | 'lg'Default md
The room a row gets: its minimum height, padding, gap and type size. Density is set by the application; size is set per list.
marker'none' | 'bullet' | 'number'Default none
What is painted in the marker column. List draws the marker itself, so removing it never removes the list semantics.
orderedbooleanDefault false
Renders an ol, so the reading order of the rows is part of the markup rather than only of the look.
insetbooleanDefault false
Removes the rows' inline padding, for a list inside a box that already pads its content. Rules and hover fills still run edge to edge.
fill'row' | 'inset'Default row
How a row draws its hover, pressed, selected and current grounds. row: edge to edge of the list. inset, for a plain or ruled list inside a container that pads its content: as a tile with the row radius that reaches past the content by --slotted-list-fill-inset on each side, while the content keeps the inline edge of the container. A framed or separated list keeps row.
loadingbooleanDefault false
Writes aria-busy on the list and draws nothing. Skeleton, composed inside the rows, stands in for their content.
level'none' | '1' | '2' | '3' | '4' | '5' | '6'Default 3
On ListSectionThe heading element a group name renders as. none renders a div, which is not announced as a heading.
stickybooleanDefault false
On ListSectionKeeps a group name in place while its own rows scroll past it, above the rows and on the list surface.
endReactNode
On ListSectionWhat stands at the end of the group heading, on the line of the name, in tabular figures.
labelVariant'caption' | 'ruled'Default caption
On ListSectionHow the group heading is drawn: caption is the small muted name, ruled is the name over a rule with no background.
labelReactNode
On ListSectionThe group name. The nested list is named by it through aria-labelledby.
labelProps / listPropsHTMLAttributes
On ListSectionProps for the heading and the nested list elements, for an id or a class the page owns.
render(props) => ReactNode
On List, ListSection, ListEmptyRenders the part's props into another element, such as a router's own list.
refRef<HTMLElement>
On every partReaches the native element. Each part accepts the props of its own element.
aria-label / aria-labelledbystring
The list's accessible name, passed through to the element. List adds no name of its own.
ListDefaultsProvider{ variant, size, marker, inset }
On a subtreeSets variant, size, marker and inset once for every list under it. A prop set on a list still wins.

Parts

PartElementRequiredPurpose
rootul or ol, or the element render returnsYesThe list. It carries data-ui="list", the three axes, data-inset, data-loading and role="list". The role is not redundant: List draws its own marker, and Safari drops list semantics when CSS removes the native one.
sectionliNoOne group: the li that holds a heading and the rows under it, which is the grouping HTML already has.
section-labelh1 to h6, or a divNoThe group name. It carries the id the nested list is named by, data-sticky when it holds still while its own rows scroll past, and data-variant: caption, the small muted name, or ruled, the name in the text color over a rule with no background.
section-endspanNoWhat stands at the end of the heading, on the line of the name: a day's total, a count. It is set in tabular figures and rendered from the end prop.
section-listul or olNoThe rows of one group. It takes the element of the list around it, carries role="list" for the same reason the root does, and is named by the heading above it.
emptyliNoThe message the list shows when it holds no rows. It sits inside the list, so a screen reader reads the message rather than announcing zero items and stopping.

Theming

Each token is a CSS custom property: set it in a theme, or on any element to retune every list inside it.

List tokens

TokenDefault
--slotted-list-backgroundvar(--slotted-surface, Canvas)
--slotted-list-border-colorvar(--slotted-border-subtle, ButtonBorder)
--slotted-list-border-widthvar(--slotted-border-width-thin, 1px)
--slotted-list-empty-colorvar(--slotted-text-muted, GrayText)
--slotted-list-empty-paddingvar(--slotted-space-8, 1.5rem)
--slotted-list-empty-padding-lgvar(--slotted-space-9, 2rem)
--slotted-list-empty-padding-smvar(--slotted-space-6, 1rem)
--slotted-list-fill-insetvar(--slotted-space-3, 0.375rem)
--slotted-list-gapvar(--slotted-space-3, 0.375rem)
--slotted-list-gap-lgvar(--slotted-space-4, 0.5rem)
--slotted-list-gap-smvar(--slotted-space-2, 0.25rem)
--slotted-list-padding-inlinevar(--slotted-control-padding-inline-md, 13px)
--slotted-list-padding-inline-lgvar(--slotted-control-padding-inline-lg, 16px)
--slotted-list-padding-inline-smvar(--slotted-control-padding-inline-sm, 10px)
--slotted-list-radiusvar(--slotted-radius-md, 6px)
--slotted-list-section-backgroundvar(--slotted-surface, Canvas)
--slotted-list-section-colorvar(--slotted-text-muted, GrayText)
--slotted-list-section-font-sizevar(--slotted-font-size-xs, 0.75rem)
--slotted-list-section-font-weightvar(--slotted-font-weight-semibold, 600)
--slotted-list-section-letter-spacing0
--slotted-list-section-padding-blockvar(--slotted-space-4, 0.5rem)
--slotted-list-section-padding-block-lgvar(--slotted-space-5, 0.75rem)
--slotted-list-section-padding-block-smvar(--slotted-space-3, 0.375rem)
--slotted-list-section-rule-colorvar(--slotted-border-subtle, GrayText)
--slotted-list-section-ruled-colorvar(--slotted-text, CanvasText)

Theme tokens it reads

TokenDefault
--slotted-border-subtleSet per scheme by the theme
--slotted-border-width-thin1px
--slotted-control-padding-inline-lgcomfortable 16px · compact 12px · dense 10px
--slotted-control-padding-inline-mdcomfortable 13px · compact 10px · dense 8px
--slotted-control-padding-inline-smcomfortable 10px · compact 8px · dense 6px
--slotted-font-size-xs0.75rem
--slotted-font-weight-medium500
--slotted-font-weight-semibold600
--slotted-line-height-sm1.45
--slotted-radius-md6px
--slotted-space-20.25rem
--slotted-space-30.375rem
--slotted-space-40.5rem
--slotted-space-50.75rem
--slotted-space-61rem
--slotted-space-81.5rem
--slotted-space-92rem
--slotted-surfaceSet per scheme by the theme
--slotted-textSet per scheme by the theme
--slotted-text-mutedSet per scheme by the theme
--slotted-z-index-sticky100