TableContainer — spec¶
Synthesized from MUI
TableContainer. Wraps aTableto provide horizontal scroll, fixed height (with sticky header), and Paper styling. Without it, wide tables overflow the viewport ungracefully.
When to use¶
- Every
Tablethat might exceed viewport width on narrow screens. - Tables inside Cards/Papers where you want consistent elevation.
- Tables with
stickyHeader(requiresmaxHeighton container).
API¶
<TableContainer component={Paper} sx={{ maxHeight: 480 }}>
<Table stickyHeader>
<TableHead>...</TableHead>
<TableBody>...</TableBody>
</Table>
</TableContainer>
| Prop | Type | Default | Description |
|---|---|---|---|
children |
ReactNode |
— | A Table |
component |
ElementType |
'div' |
Wrap as Paper for elevation |
Tokens consumed¶
Accessibility¶
- The container itself adds no a11y semantics.
- For very wide tables that scroll horizontally, ensure keyboard users can navigate (the table itself stays focusable; arrow keys move within cells).
- Set
tabIndex={0}+role="region"+aria-labelon the container to make scrolling discoverable to screen readers.
Edge cases¶
stickyHeaderwithoutmaxHeight— header doesn't stick (needs a scrollable parent).- Mobile pivot to card-list — for very narrow viewports, breaking out of TableContainer entirely and rendering
<Stack><Card /></Stack>reads better than horizontal scroll. Citeknowledge/patterns/list-and-feed.md.
Code example¶
<TableContainer
component={Paper}
sx={{ maxHeight: 480 }}
tabIndex={0}
role="region"
aria-label="직원 명단"
>
<Table stickyHeader>
<TableHead>...</TableHead>
<TableBody>...</TableBody>
</Table>
</TableContainer>
Don't¶
- Don't use without a
Tablechild. - Don't apply both
maxHeightandheight: 100%— unpredictable layout.
References¶
- MUI:
TableContainer