I'm trying to do exactly the same as this post but with the implementation on a MUI Grid container/item. The result though is that I don't have a scrollbar and I can't scroll. Is there something wrong with my implementation?
Here is the codebox
Thanks in advance for your time.
Edit, apparently the links are working so I'm altering this post with both the links and the code.
Links:
- Hide scroll bar, but while still being able to scroll
- https://codesandbox.io/p/sandbox/scrollable-grid-8jrc3n?file=%2Fsrc%2FScrollableGrid.tsx
Code:
const ScrollableGrid: React.FC = () => {
return (
<Grid
container
sx={{ overflow: "hidden", maxHeight: "300px", border: "1px solid green" }}
>
<Grid
item
xs={12}
sx={{
overflowY: "auto",
height: "100%",
boxSizing: "content-box",
border: "1px solid red",
margin: "10px",
}}
>
<div>Text 1</div>
<br />
<div>Text 2</div>
<br />
<div>Text 3</div>
<br />
<div>Text 4</div>
<br />
<div>Text 5</div>
<br />
<div>Text 6</div>
<br />
<div>Text 7</div>
<br />
<div>Text 8</div>
<br />
<div>Text 9</div>
<br />
<div>Text 10</div>
<br />
<div>Text 11</div>
<br />
<div>Text 12</div>
<br />
</Grid>
</Grid>
);
};
As my comment worked, I'm adding this for other users.
You can hide the scrollbar but keep the functionality like so:
Code Sandbox