You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The class is the penultimate one in the list of classes applies to the button. As a result, the style may not be applied to the button.
Expected behavior
The class added as a className attribute should be applied last in the list of classes for the button, so that its styles get applied to the button.
Context
I try to apply some styles from Tailwind CSS to a button, which can't be easily accomplished as Tailwind CSS styles get overridden by the ones added by Material UI on the button's last class.
You need to add the important option to your tailwind.config.js. Most CSS classes used by Material UI have a specificity of 1 but there are exceptions.
Thanks @alelthomas for your help!
Nice to know that it is documented already.
I didn't see this part of the docs, but still used important option indeed. However I thought it was some kind of hacky way to solve it.
I checked the injectFirst option on StyledEngineProvider too, with no luck.
I guess that having custom classes at the end of the list of classes would be a solution that would make sense, avoiding quite some "aha" moments! But I am not sure about possible breaking changes that would involve.
So feel free to close this issue if you think that it's not something that would make sense for MUI.
This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.
Note
@michaelperrin How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey.
Steps to reproduce
Link to live example: https://codesandbox.io/p/sandbox/gt78v7
Steps:
ml-5
), or the class defined in the CSS file.In the Codesandbox I provided, the margin doesn't get applied to the button, as Material UI defines margin properties on the last class element.
Note that this issue was already reported here, but got closed.
Current behavior
The class is the penultimate one in the list of classes applies to the button. As a result, the style may not be applied to the button.
Expected behavior
The class added as a className attribute should be applied last in the list of classes for the button, so that its styles get applied to the button.
Context
I try to apply some styles from Tailwind CSS to a button, which can't be easily accomplished as Tailwind CSS styles get overridden by the ones added by Material UI on the button's last class.
Your environment
npx @mui/envinfo
Browser used: Firefox
Search keywords: button,className
The text was updated successfully, but these errors were encountered: