How does one add vertical scrolling functionality to a grid container, such that its components can be vertically scrolled through if the height of the components exceeds some max?
Asked
Active
Viewed 2,757 times
1 Answers
4
Assuming you're using the latest MUI, it can be as simple as adding overflowY: 'scroll'
and setting a maxHeight
via the Grid
container's sx
prop (or its parent element). For example:
<Grid
sx={{ overflowY: "scroll", maxHeight: "250px" }}
container
spacing={2}
>
...
</Grid>
Working CodeSandbox: https://codesandbox.io/s/mui-5-scrollable-grid-gjxfq?file=/demo.js

Steve
- 11,596
- 7
- 39
- 53
-
JFYI dear reader, you can customize the scrollbar just like this: https://stackoverflow.com/a/71893788/8784518 – Kasir Barati May 06 '23 at 13:35