[Autocomplete] Flatten CSS specificity (easier overrides)
See original GitHub issueI am trying to apply custom styles for components via theme.components
so that all related material ui components styles gets applied. But due to specificity issues, some are not getting overriden.
- [ x] The issue is present in the latest alpha release.
- [x ] I have searched the issues of this repository and believe that this is not a duplicate.
Current Behavior 😯
Styles applied via theme.components
(of createMuiTheme
) should getting overriden due to CSS specificity
Expected Behavior 🤔
Styles applied via theme.components
(of createMuiTheme
) should not get overriden due to CSS specificity
Steps to Reproduce 🕹
Steps:
Applied following style to AutoComplete
is expected to override padding.
const theme = createMuiTheme({
components: {
MuiAutocomplete: {
styleOverrides: {
inputRoot: {
padding: "3px"
},
input: {
padding: "3px"
}
}
}
}
});
CodesanboxLink: https://codesandbox.io/s/combobox-styles-override-problem-0ngl4?file=/index.tsx
Context 🔦
Your Environment 🌎
`npx @material-ui/envinfo`
Don't forget to mention which browser you used.
Output from `npx @material-ui/envinfo` goes here.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:13 (9 by maintainers)
Top Results From Across the Web
[Autocomplete] Flatten CSS specificity (easier overrides) #25840
I am trying to apply custom styles for components via theme.components so that all related material ui components styles gets applied.
Read more >How can I override autocomplete selected option in material ...
How can I override the selected options Css in autocomplete material UI, how it can be done with help of theme.
Read more >Strategies for Keeping CSS Specificity Low
Reduce the specificity of the thing you're overriding Definitely do a project-wide search for #that before you do it. It might be being...
Read more >Specificity - CSS: Cascading Style Sheets - MDN Web Docs
The specificity algorithm calculates the weight of a CSS selector to ... styles are easily overridden with slightly more specific rules.
Read more >Autocomplete attribute has valid value | ACT Rule | WAI - W3C
Description. This rule checks that the HTML autocomplete attribute has a correct value. Applicability. This rule applies to any HTML input , select...
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
Working on this 🙂
@mnajdova Do we really need a CSS selector of this depth
.css-1n1au9f-MuiAutocomplete-root .MuiAutocomplete-inputRoot.MuiOutlinedInput-root .MuiAutocomplete-input
? What about we flatten the specificity by 1 level (4 -> 3)?