List
Rows of related things: people, messages, settings, files. Each row has a title with room on either side for an avatar or icon and for a time, a switch or an arrow. A whole row can be one link or button.
Install
npx shadcn@latest add @nelumbo/listMessages
Avatars lead, a time and a count trail. Each row is a button (onClick), so the whole row is one target; screen readers hear the name, then the message. The open conversation is selected.
Segmented
variant="segmented" puts each row on its own tile, 2px apart, with the group's outer corners rounded. Subheaders and dividers start a new group. Rows can link somewhere (href) or hold a control.
- Connections
- Display and sound
Selection
With asChild, the title can be your own element. Here it's the checkbox's label, so a click anywhere on the row ticks it.
Plain, with dividers
Static rows, with an overline, a description, and an inset divider that starts after the leading slot.
Usage
import { List, ListDivider, ListItem, ListSubheader } from "@/components/ui/list"<List variant="segmented"> <ListSubheader>Connections</ListSubheader> <ListItem icon="wifi" description="Studio 5G" trailing={<Switch aria-label="Wi-Fi" />}>Wi-Fi</ListItem> <ListItem icon="palette" href="/settings/display" trailingIcon="chevron_right">Display</ListItem></List>// your own link<ListItem asChild leading={<Avatar name={user.name} />} description={user.email}> <Link href={`/people/${user.id}`}>{user.name}</Link></ListItem>Props
| Prop | Type | Default | Notes |
|---|---|---|---|
List variant | "plain" | "segmented" | "plain" | Segmented: rows on tiles, grouped |
ListItem children | ReactNode | The title | |
icon / leading | IconName / ReactNode | A Material Symbol, or an avatar, image or checkbox | |
overline / description | ReactNode | Above and below the title; the description clamps to 2 lines | |
meta | ReactNode | Short trailing text: a time, a count | |
trailing / trailingIcon | ReactNode / IconName | A control (stays clickable), or an icon | |
href / onClick / asChild | Make the row one link or button; asChild for your own | ||
selected | boolean | false | Filled, and aria-current |
disabled | boolean | false | |
align | "center" | "top" | "center" | Top for long descriptions |
ListDivider inset | boolean | false | Start after the leading slot |