TableBody — spec¶
Synthesized from MUI
TableBody. The container for data rows in aTable. Equivalent to<tbody>with consistent styling defaults.
When to use¶
- Inside every
Tablethat displays data rows. - For tables with no body (header-only summary), omit.
API¶
<Table>
<TableHead>...</TableHead>
<TableBody>
{rows.map((row) => (
<TableRow key={row.id}>
<TableCell>{row.name}</TableCell>
</TableRow>
))}
</TableBody>
</Table>
| Prop | Type | Default | Description |
|---|---|---|---|
children |
ReactNode |
— | TableRow children |
component |
ElementType |
'tbody' |
Override |
Accessibility¶
Renders <tbody> — semantic role for table body comes for free. No additional ARIA needed.
Edge cases¶
- Empty state — when
rows.length === 0, render a singleTableRowwith oneTableCellspanning all columns containing the empty-state message. Citeknowledge/patterns/empty-states.md. - Loading state — show skeleton rows or a single overlay. Don't leave the body empty during fetch — users see a flash.
- Virtualization — for 100+ rows, use a virtualized table library (TanStack Virtual + MUI Table). MUI's
TableBodydoesn't virtualize automatically.
Code example¶
{isLoading ? (
<TableBody>
{Array.from({ length: 5 }).map((_, i) => (
<TableRow key={i}>
{columns.map((col) => (
<TableCell key={col.key}><Skeleton /></TableCell>
))}
</TableRow>
))}
</TableBody>
) : rows.length === 0 ? (
<TableBody>
<TableRow>
<TableCell colSpan={columns.length} align="center" sx={{ py: 8 }}>
결과가 없어요
</TableCell>
</TableRow>
</TableBody>
) : (
<TableBody>
{rows.map((row) => <TableRow key={row.id}>...</TableRow>)}
</TableBody>
)}
Don't¶
- Don't render rows outside
TableBody(orTableHead/TableFooter). - Don't use for content that isn't tabular — Cards / Stacks fit better.
References¶
- MUI:
TableBody