Data display
Expandable rows
A table row that opens a detail panel under itself
Name
Size
Modified
harbour-chart.png
1.4 MB
24 Oct
KindPNG image
Size1.4 MB
Ownerdesign
Modified24 Oct
notes.md
12 KB
23 Oct
deploy.log
318 KB
22 Oct
budget.csv
48 KB
20 Oct
1 of 4 panels open
TableExpandableRow opens a detail panel under its row.
Usage
import {
Table,
TableBody,
TableExpandableRow,
TableHeader,
TableHeaderCell,
TableRow,
TableViewport,
} from "@gpuixui/data";
import { useState } from "react";
const [open, setOpen] = useState<string | null>(null);
<Table height={300} aria-label="Files with details">
<TableViewport>
<TableHeader>
<TableRow>
<TableHeaderCell width={32} />
<TableHeaderCell width={200}>Name</TableHeaderCell>
</TableRow>
</TableHeader>
<TableBody>
{files.map((file) => (
<TableExpandableRow
key={file.id}
expanded={open === file.id}
onToggle={() => setOpen(open === file.id ? null : file.id)}
cells={<TableCell width={200}>{file.name}</TableCell>}
detail={<KeyValue entries={detailOf(file)} />}
/>
))}
</TableBody>
</TableViewport>
</Table>;API
TableExpandableRow
| Prop | Type | Default | Consequence |
|---|---|---|---|
expanded | boolean | false | the panel under the row paints |
onToggle | () => void | — | the row's press, and the activation its Enter/Space makes; the caller flips expanded |
cells | ReactNode | — | the row's cells, after the expander track |
detail | ReactNode | — | the panel painted under the row while it is open |
toggleWidth | number | 32 | the expander track's width |
detailTestId | string | — | the panel's test id |
selected | boolean | false | the row is chosen: it paints the selection wash (from TableRow) |
disabled | boolean | false | refuses the press and the keys, and paints no pointer state |
tabIndex | number | 0 | the row's place in the Tab order; a disabled row takes -1 |
instanceRef | Ref<PublicInstance> | — | the row's painted element, for moving native focus to it |
className | string | — | joined after the row's recipe |
Keyboard
- EnterSpace
- expands or collapses the row
read from expandable.tsx
Edit this page on GitHubpackages/data/docs/expandable-rows.mdx