[Select] style overrides overwritten by hardcoded values
See original GitHub issue- The issue is present in the latest release.
- I have searched the issues of this repository and believe that this is not a duplicate.
Current Behavior 😯
With the move to using emotion MuiSelect styleOverrides are being overwritten. CodeSandbox
It looks as though it’s not emotion, rather hardcoded values that I’m not sure can be overwritten - PR change
const SelectRoot = experimentalStyled(
'div',
{},
{ name: 'MuiSelect', slot: 'Root', overridesResolver },
)(nativeSelectRootStyles, {
[`&.${selectClasses.selectMenu}`]: {
height: 'auto', // Resets for multiple select with chips
minHeight: '1.4375em', // Required for select\text-field height consistency
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
overflow: 'hidden',
},
});
Expected Behavior 🤔
MuiSelect styleOverrides in theme should be applied. CodeSandbox
Without adding any style overrides we get the following CSS
.MuiSelect-selectMenu {
height: auto;
overflow: hidden;
min-height: 1.4375em;
white-space: nowrap;
text-overflow: ellipsis;
}
adding in the following style overrides
const theme = createMuiTheme({
components: {
MuiSelect: {
defaultProps: {
displayEmpty: true,
variant: "outlined"
},
styleOverrides: {
selectMenu: {
height: "auto",
minHeight: "32px"
}
}
}
}
});
changes the CSS to
.MuiSelect-selectMenu {
height: auto;
overflow: hidden;
min-height: 32px;
white-space: nowrap;
text-overflow: ellipsis;
}
as expected.
Steps to Reproduce 🕹
Steps:
See CodeSandbox links
Context 🔦
Our Select styles are not being applied to our component
Your Environment 🌎
`npx @material-ui/envinfo`
System:
OS: macOS 11.2.1
Binaries:
Node: 15.2.1 - /usr/local/bin/node
Yarn: 1.22.10 - /usr/local/bin/yarn
npm: 7.0.10 - /usr/local/bin/npm
Browsers:
Chrome: 89.0.4389.128. <-----
Edge: Not Found
Firefox: 87.0
Safari: 14.0.3
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:7 (5 by maintainers)
Top Results From Across the Web
[Select] style overrides overwritten by hardcoded values #25763
The issue is present in the latest release. I have searched the issues of this repository and believe that this is not a...
Read more >Overriding Material-UI Select Style - Stack Overflow
I am trying to override the styling applied by Material-UI's <Select> component ... https://codesandbox.io/s/overwrite-select-style-zqk1r.
Read more >Override Inline Styles with CSS
Often we think of inline styles as a way to override styles we set up in the CSS. 99% of the time, this...
Read more >Breaking changes in v5, part one: styles and themes - MUI
Although your style overrides defined in the theme may partially work, there is an important difference regarding how the nested elements are styled....
Read more >Global style variations - Full Site Editing
In my case, I replaced some hard-coded CSS values with CSS custom properties in theme.json so that I could override the values using...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Not to resurrect an issue that is probably resolved, but I can’t seem to figure out how to change the height of the Select in MUI 5. I have the following in my theme:
I can’t seem to get that style, or frankly any style within the the styleOverrieds of Select to work.
I actually get an TS error: