Autocomplete custom styles get overwritten by MUI styles (v5)
See original GitHub issueDuplicates
- I have searched the existing issues
Latest version
- I have tested the latest version
Current behavior 😯
After upgrading to MUI5, the autocomplete options custom styles are loaded after the MUI styles which makes me use !important to override the styles.
Expected behavior 🤔
My styles should be loaded first like in other components in order to avoid the use of !important.
Your environment 🌎
`npx @mui/envinfo`
System:
OS: macOS 11.6.2
Binaries:
Node: 14.16.0 - ~/.nvm/versions/node/v14.16.0/bin/node
Yarn: 1.22.10 - /usr/local/bin/yarn
npm: 6.14.11 - ~/.nvm/versions/node/v14.16.0/bin/npm
Browsers:
Chrome: 96.0.4664.110
Edge: Not Found
Firefox: 93.0
Safari: 15.2
npmPackages:
@emotion/react: ^11.5.0 => 11.5.0
@emotion/styled: ^11.3.0 => 11.3.0
@mui/core: 5.0.0-alpha.54
@mui/lab: ^5.0.0-alpha.54 => 5.0.0-alpha.54
@mui/material: ^5.1.0 => 5.1.0
@mui/private-theming: 5.1.0
@mui/styled-engine: 5.1.0
@mui/styles: ^5.1.0 => 5.1.0
@mui/system: 5.1.0
@mui/types: 7.1.0
@mui/utils: 5.1.0
@types/react: ^17.0.22 => 17.0.24
react: 17.0.2 => 17.0.2
react-dom: 17.0.2 => 17.0.2
typescript: ^4.4.3 => 4.4.3
Issue Analytics
- State:
- Created 2 years ago
- Comments:16 (7 by maintainers)
Top Results From Across the Web
How to change styles of Material-UI Autocomplete list?
One way of doing this is by adjusting the elevation of the Paper component used by Autocomplete . The default elevation is 1....
Read more >MUI v5 -> How to style options inside Autocomplete ...
I'm trying to apply some basic styles to the options inside the Autocomplete component from MUI v5. I'm just trying to change the...
Read more >Autocomplete API - Material UI
Name Type Default
options * array
renderInput * func
autoComplete bool false
Read more >Custom React Component styles being overwritten by ...
Coding example for the question Custom React Component styles being overwritten by Material-UI style-Reactjs.
Read more >Global Styling with Material-UI Theme Overrides and Props
Learn how to use global CSS overrides and default props in a theme to customize all instances of a Material-UI component in a...
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
You are not based on the code. You should use something like:
styles.css
If there are problems please create a codesandbox, otherwise, it’s hard to iterate and verify that it works. cc @hbjORbj probably these are more opportunities for improving the migration guide.
We’re probably missing something, but Dialog doesn’t seem to append the custom styles at the end?
In this codesanbox, we create a custom Paper component and use it in Dialog:
But somehow our custom style rules are not appended at the end of the Paper class, so we can’t override
max-width
:However, if we wrap our custom style with
& { ... }
, then the custom styles are in their own inline style tag, and thus works:codesandbox
Question:
Is it normal that sometimes custom styles are appended at the end of the rules and sometimes it’s not?
Our suspicion is that perhaps our custom styles are in the middle of the
MuiDialog-paper
css class, becauseDialog
adds more default MUI styles to itsPaperComponent
, thus overriding our customStyledPaper
. And if this is the intended behavior, is& { ... }
the recommended solution?Thank you!
CC: @mnajdova please kindly help take a look at this if possible, since resolving/clarifying this will help our company’s design system MUIv5 roll out 😄 🙏
UPDATE: Created a separate issue for SEO!