Reputation: 951
In my project I am using material ui Select component and the problem is that dropdown contents is very long and does not fit in.
For these purposes I need to add a horizontal scroll to dropdown menu. I tried adding property OverflowX to menuProps and to sx props but it did not work. Any ideas how to fix the issue?
Upvotes: 1
Views: 7476
Reputation: 1085
Problem is this part of the code.
const MenuProps = {
autoFocus: false,
//OverflowX: "scroll",
PaperProps: {
style: {
//maxHeight: ITEM_HEIGHT * 4.5 + ITEM_PADDING_TOP,
width: 250,
OverflowX: "scroll"
}
}
};
width
and overflowX
, so you were really close the styling is correct just fix width and overflow.
const MenuProps = {
autoFocus: false,
//OverflowX: "scroll",
PaperProps: {
style: {
//maxHeight: ITEM_HEIGHT * 4.5 + ITEM_PADDING_TOP,
width: "250px",
overflowX: "scroll"
}
}
};
Upvotes: 0
Reputation: 1274
Added a codesandbox link. You can check the solution here.
https://codesandbox.io/s/selectautowidth-demo-material-ui-forked-8yl3n9?file=/demo.js
Upvotes: 2