<!-- index: /slotted/llms.txt -->
# list

`data-ui="list"` · Vertical list of items with sections.

## Import

```tsx
import { List, ListDefaultsProvider, ListEmpty, ListSection } from '@slotted/react';
```

## Minimal example

Example

```tsx
import { List } from '@slotted/react/list';
import {
  ListItem,
  ListItemBody,
  ListItemDescription,
  ListItemEnd,
  ListItemLabel,
  ListItemLink,
} from '@slotted/react/list-item';

const WAREHOUSES = [
  { id: 'reno', name: 'Reno', summary: '312 orders to ship today', open: '1,284' },
  { id: 'columbus', name: 'Columbus', summary: '198 orders to ship today', open: '962' },
  { id: 'savannah', name: 'Savannah', summary: '74 orders to ship today', open: '418' },
];

export default function ListBasic() {
  return (
    <List aria-label="Warehouses" variant="ruled">
      {WAREHOUSES.map((warehouse) => (
        <ListItem key={warehouse.id}>
          <ListItemLink href={`#${warehouse.id}`}>
            <ListItemBody>
              <ListItemLabel>{warehouse.name}</ListItemLabel>
              <ListItemDescription>{warehouse.summary}</ListItemDescription>
            </ListItemBody>
            <ListItemEnd>{warehouse.open}</ListItemEnd>
          </ListItemLink>
        </ListItem>
      ))}
    </List>
  );
}
```

## Anatomy

| Part | Element | Required |
| --- | --- | --- |
| `root` | ul or ol, or the element render returns | yes |
| `section` | li | no |
| `section-label` | h1 to h6, or a div | no |
| `section-end` | span | no |
| `section-list` | ul or ol | no |
| `empty` | li | no |

## Props

| Name | Type | Default | Applies to | Description |
| --- | --- | --- | --- | --- |
| `variant` | `'plain' \| 'ruled' \| 'framed' \| 'separated'` | plain | List | 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'` | md | List | 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'` | none | List | What is painted in the marker column. List draws the marker itself, so removing it never removes the list semantics. |
| `ordered` | `boolean` | false | List | Renders an ol, so the reading order of the rows is part of the markup rather than only of the look. |
| `inset` | `boolean` | false | List | 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'` | row | List | 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. |
| `loading` | `boolean` | false | List | 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'` | 3 | ListSection | The heading element a group name renders as. none renders a div, which is not announced as a heading. |
| `sticky` | `boolean` | false | ListSection | Keeps a group name in place while its own rows scroll past it, above the rows and on the list surface. |
| `end` | `ReactNode` | — | ListSection | What stands at the end of the group heading, on the line of the name, in tabular figures. |
| `labelVariant` | `'caption' \| 'ruled'` | caption | ListSection | How the group heading is drawn: caption is the small muted name, ruled is the name over a rule with no background. |
| `label` | `ReactNode` | — | ListSection | The group name. The nested list is named by it through aria-labelledby. |
| `labelProps / listProps` | `HTMLAttributes` | — | ListSection | Props for the heading and the nested list elements, for an id or a class the page owns. |
| `render` | `(props) => ReactNode` | — | List, ListSection, ListEmpty | Renders the part's props into another element, such as a router's own list. |
| `ref` | `Ref<HTMLElement>` | — | every part | Reaches the native element. Each part accepts the props of its own element. |
| `aria-label / aria-labelledby` | `string` | — | List | The list's accessible name, passed through to the element. List adds no name of its own. |
| `ListDefaultsProvider` | `{ variant, size, marker, inset }` | — | a subtree | Sets variant, size, marker and inset once for every list under it. A prop set on a list still wins. |

## Axes and defaults

| Axis | Values | Default |
| --- | --- | --- |
| `variant` | `plain`, `ruled`, `framed`, `separated` | `plain` |
| `size` | `sm`, `md`, `lg` | `md` |
| `marker` | `none`, `bullet`, `number` | `none` |
| `fill` | `row`, `inset` | `row` |

## Rules

- 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.

## Tokens

`--slotted-border-subtle`, `--slotted-border-width-thin`, `--slotted-control-padding-inline-lg`, `--slotted-control-padding-inline-md`, `--slotted-control-padding-inline-sm`, `--slotted-font-size-xs`, `--slotted-font-weight-medium`, `--slotted-font-weight-semibold`, `--slotted-line-height-sm`, `--slotted-list-background`, `--slotted-list-border-color`, `--slotted-list-border-width`, `--slotted-list-empty-color`, `--slotted-list-empty-padding`, `--slotted-list-empty-padding-lg`, `--slotted-list-empty-padding-sm`, `--slotted-list-fill-inset`, `--slotted-list-gap`, `--slotted-list-gap-lg`, `--slotted-list-gap-sm`, `--slotted-list-padding-inline`, `--slotted-list-padding-inline-lg`, `--slotted-list-padding-inline-sm`, `--slotted-list-radius`, `--slotted-list-section-background`, `--slotted-list-section-color`, `--slotted-list-section-font-size`, `--slotted-list-section-font-weight`, `--slotted-list-section-letter-spacing`, `--slotted-list-section-padding-block`, `--slotted-list-section-padding-block-lg`, `--slotted-list-section-padding-block-sm`, `--slotted-list-section-rule-color`, `--slotted-list-section-ruled-color`, `--slotted-radius-md`, `--slotted-space-2`, `--slotted-space-3`, `--slotted-space-4`, `--slotted-space-5`, `--slotted-space-6`, `--slotted-space-8`, `--slotted-space-9`, `--slotted-surface`, `--slotted-text`, `--slotted-text-muted`, `--slotted-z-index-sticky`

## Examples

See [list.examples.md](./list.examples.md).
