-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Menu][discussion] Menu height/padding changes in 4.5 should be under a dense
flag
#17701
Comments
This is one of the most controversial changes we have introduced since v4.0.0. I wouldn't be surprised if we get similar feedback for this change in the future. The component still has a dense mode. It will reduce the font size and apply the same small height it has on the desktop to the mobile environment. As far as I have explored the specification, the instructions are inconsistent. I think that it's significantly better than the height we had on desktop prior to v4.5.0. |
@oliviertassinari do you have any insights about my question? |
Any "migration" guide for this? This change has screwed up most of my current UI; I now have different sizes everywhere. Or at least, how can I make and components behave like these menu items? Custom components relying on will now have a smaller size than regular menu/select fields... Very annoying. Additionally, I also need to know what's the item height going to be (due to some custom component that needs to decide on it's height). Where can get this info now that the height might adjust based on the screen size? |
@cristianoccazinsp Sure, for people that want to revert the change (to be honest, it's was definitely borderline for a minor), you can apply this patch: .MuiMenuItem-root {
padding-top: 4px;
padding-bottom: 4px;
min-height: 48;
} or with the theme: const theme = createMuiTheme()
theme.overrides = {
MuiMenuItem: {
root: {
paddingTop: 4,
paddingBottom: 4,
[theme.breakpoints.up('sm')]: {
minHeight: 48,
},
},
},
};
You can apply: .my-class {
padding-top: 6px;
padding-bottom: 6px;
min-height: 48;
}
/* theme.breakpoints.up('sm') */
@media (min-width: 600px) {
.my-class {
min-height: auto;
}
}
We use this approach in the demos: |
Thanks @oliviertassinari , that's very useful! I'm also wondering, when using |
@cristianoccazinsp The dense props behavior is intended, it reduces the font size and is dense on mobile too. |
In the 4.5 version of Material-UI the height and padding of menu items changed "to better match Google's products" in #17332. I feel like the change was unnecessary to implement as the default just because that's how Google does it. The Material Design menu documentation specifically mentions both a version with more padding as well as a dense option. The Material Design documentation should take precedence over the look of Google's products (which is pretty inconsistent). I don't think the goal of Material-UI should be to clone the look of Google's products but rather be an implementation of Material Design.
It would be a lot more logical to implement these changes under a
dense
prop this way it's an opt-in functionality and wont mess up the current styles of peoples menu's. Because in my opinion it's not a change that looks better, especially when using a different font than Roboto.The text was updated successfully, but these errors were encountered: