List
Rows with one tab stop, type-ahead and a row action
Workspace files
selected: readme · opened: none
Assign reviewers
values: grace
Installation
npx shadcn@latest add @sudokw/components-listimport { List } from "@gpuixui/components";Usage
import {
List,
ListItem,
ListItemDescription,
ListItemTitle,
} from "@gpuixui/components/list";
const files = [
{ value: "readme", title: "README.md", description: "The project's front door" },
{ value: "design", title: "Design notes", description: "docs/design-notes.md" },
];
export const FileList = ({ open }: { open: (value: string) => void }) => (
<List defaultValue="readme" onActivate={open} selectionMode="single">
{files.map((file) => (
<ListItem key={file.value} textValue={file.title} value={file.value}>
<ListItemTitle>{file.title}</ListItemTitle>
<ListItemDescription>{file.description}</ListItemDescription>
</ListItem>
))}
</List>
);Composition
List
└── ListItem
├── ListItemTitle
├── ListItemDescription
├── leading
└── trailingAPI reference
List
| Prop | Type | Default |
|---|---|---|
selectionMode | "none" | "single" | "multiple" | "none" |
value | string (single) · ReadonlyArray<string> (multiple) — controlled | — |
defaultValue | the same shape, initial selection when uncontrolled | "" · [] |
onValueChange | (value: string) => void (single) · (values: ReadonlyArray<string>) => void (multiple) | — |
onActivate | (value: string) => void — single and none only; absent from the multiple variant | — |
dense | boolean — a row at density.rowHeight instead of rowHeight + spacing.md | false |
children | parts — ListItem rows, one ListSection per group | — |
className | string — joined after the root recipe | — |
ListItem
| Prop | Type | Default |
|---|---|---|
value | string (required) | — |
textValue | string — the text type-ahead matches | — |
disabled | boolean | false |
leading | ReactNode — an icon, avatar or marker | — |
trailing | ReactNode — metadata, a badge or an action | — |
children | parts — ListItemTitle, ListItemDescription and the row's slots | — |
className | string — joined after the row recipe | — |
style | StyleDesc or a function of { active, disabled, selected } | — |
Keyboard
- Arrow DownArrow UpCtrl+NCtrl+P
- moves the focus ring
- HomeEnd
- the first or last row
- Enter
- activates the row, and selects it when the list is selectable
- Space
- selects the focused row
- Cmd/Ctrl+A
- selects every row
A typed letter jumps to the first row whose label starts with it.
read from list.tsx
Edit this page on GitHubapps/docs/content/docs/components/list.mdx