# List

A plain list of rows: people, documents, recent records. Each row takes a leading avatar or icon, a primary and a secondary line that clip with their full text on hover, trailing meta, and an action beside it. A row can be static, a link or a button; keyboard focus shows as the hover highlight, as in every list.

- Beta: ready to use; its API can still change in a minor release.
- Category: Layout & surfaces

```tsx
import { List, ListItem, ListSubheader } from "@leap-crm/design-system";
```

## Best practices

- Do: Use it for a single column of records, like recent contacts or a matter's documents, where each row is read on its own.
- Do: Put a row's More button in `action`, so it sits beside the row's link or button and controls never nest.
- Do: Set `current` on the row for the record that is open now, and give the list an `aria-label` when no heading names it.
- Do: Set `animated` when rows arrive and leave, and key each `ListItem` by its record id, so a new row slides in where the eye can find it.
- Don't: Use it when readers compare values across rows, like each matter's stage, value and owner. Use `Table`, which lines the values up in columns.
- Don't: Put a long list in an `overflow-auto` box. Wrap it in `ScrollArea` with a height or a `max-h-*`, so the scrollbar takes no room from the rows.

## Keyboard

| Keys | What they do |
| --- | --- |
| Tab | Moves through the rows that do something. |
| Enter | Follows a row that is a link. |
| Enter, Space | Presses a row that is a button. |

## Related

- [Table](./table.md)
- [Workspace Table](./workspace-table.md)
- [Card](./card.md)

## Examples

What the examples import:

```tsx
import { FileText, MoreHorizontal } from "lucide-react";
import { Avatar, Button, IconButton, IconTile, List, ListItem, ListSubheader } from "@leap-crm/design-system";
import { useState } from "react";
```

Scaffolding the examples call. It lives in the docs page, not in the library:

```tsx
const people = [
  "Ada Hartley",
  "Ben Okafor",
  "Chloe Nguyen",
  "Dev Patel",
  "Ella Rossi",
  "Finn Walsh",
];

const initialsOf = (name: string) =>
  name
    .split(" ")
    .map(part => part[0])
    .join("");

function LiveList() {
  const [names, setNames] = useState(people.slice(0, 3));
  const next = people.find(name => !names.includes(name));
  return (
    <div className="flex w-80 flex-col gap-3">
      <div className="flex gap-2">
        <Button
          intent="outline"
          size="xs"
          disabled={next === undefined}
          onClick={() => next && setNames([next, ...names])}
        >
          Add
        </Button>
        <Button
          intent="outline"
          size="xs"
          disabled={names.length === 0}
          onClick={() => setNames(names.slice(1))}
        >
          Remove first
        </Button>
        <Button
          intent="outline"
          size="xs"
          onClick={() => setNames(names.toReversed())}
        >
          Reverse
        </Button>
      </div>
      <List animated dividers aria-label="Watching">
        {names.map(name => (
          <ListItem
            key={name}
            leading={
              <Avatar name={name} initials={initialsOf(name)} size="md" />
            }
            primary={name}
            secondary="Added to the matter"
          />
        ))}
      </List>
    </div>
  );
}
```

### Rows arriving and leaving

animated: a new row slides in with a brief tint so the eye finds it, a removed one fades while the rest close up, and reordered rows glide to their places. Rows there on first render stay still. Key each row by its record. Reduced motion keeps the fade and tint and drops the movement.

```tsx
<LiveList />
```

### Links with a subheader

Rows that open records. The current one keeps the navy tint; Tab through to see the highlight.

```tsx
<List className="w-96" aria-label="Contacts">
  <ListSubheader>Recent</ListSubheader>
  <ListItem
    leading={<Avatar name="Ada Hartley" initials="AH" size="md" />}
    primary="Ada Hartley"
    secondary="ada@hartley.com.au"
    trailing="2d"
    href="/list"
    current
  />
  <ListItem
    leading={<Avatar name="Ben Okafor" initials="BO" size="md" />}
    primary="Ben Okafor"
    secondary="ben.okafor@outlook.com"
    trailing="5d"
    href="/list"
  />
  <ListSubheader>Organisations</ListSubheader>
  <ListItem
    leading={
      <Avatar
        name="Hartley Okafor Moreau Family Trust"
        initials="HT"
        size="md"
        person="contact"
      />
    }
    primary="Hartley Okafor Moreau Family Trust (Superannuation Fund No. 2)"
    secondary="Trust"
    trailing="1w"
    href="/list"
  />
</List>
```

### Static, with dividers and actions

dividers puts a hairline between rows. The More button is the row's action: it sits beside the row, never inside it.

```tsx
<List dividers className="w-96" aria-label="Documents">
  {[
    "Cost agreement.pdf",
    "Contract of sale.docx",
    "Identity check.pdf",
  ].map(name => (
    <ListItem
      key={name}
      leading={<IconTile icon={<FileText />} tone="info" size={28} />}
      primary={name}
      secondary="Updated 21 Nov 2026"
      action={
        <IconButton
          size="sm"
          icon={<MoreHorizontal />}
          aria-label={`More for ${name}`}
        />
      }
    />
  ))}
</List>
```

## Props

### List

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `dividers` | `boolean` | `false` | Puts a hairline between rows. |
| `animated` | `boolean` | `false` | Rows that arrive slide in with a brief tint, rows that leave fade out while the rest close up, and reordered rows glide. Rows there on first render stay still. Key every ListItem by its record, not its index. |
| `className` | `string` |  | Classes added to the root element, merged with its own. Tokens only. |

### ListItem

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `leading` | `ReactNode` |  | An Avatar, IconTile or 16 px icon before the text. |
| `primary` (required) | `ReactNode` |  | The row's main text. It clips with its full text on hover. |
| `secondary` | `ReactNode` |  | A quieter line under it. |
| `trailing` | `ReactNode` |  | Quiet meta at the end of the row, like a date. |
| `action` | `ReactNode` |  | A control beside the row, like a More button. It sits outside the row's link or button, so controls don't nest. |
| `href` | `string` |  | Makes the row a link. |
| `onClick` | `MouseEventHandler<HTMLButtonElement>` |  | Makes the row a button. |
| `render` | `ReactElement<{ className?: string; children?: ReactNode }>` |  | Renders the row as another element, like a router Link. |
| `current` | `boolean` | `false` | Marks the row as the one shown now, like the open record. |
| `className` | `string` |  | Classes added to the root element, merged with its own. Tokens only. |

### ListSubheader

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `children` (required) | `ReactNode` |  | What it shows inside. |
| `className` | `string` |  | Classes added to the root element, merged with its own. Tokens only. |
