-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tailwind styles aren't applied to Popover Menus when following Tailwind MUI interoperability docs #33017
Comments
Maybe @robertwt7 can help out here. |
I鈥檓 thinking I鈥檒l have to use the |
This is actually a good point, any reason from the MUI team why |
Sounds about right, it should be similar to as described in #33007 for the shallow dom - https://deploy-preview-33007--material-ui.netlify.app/material-ui/guides/shadow-dom/ :) This deserves an docs update on our interoperability guide with Tailwind CSS - https://mui.com/material-ui/guides/interoperability/#tailwind-css and maybe even updating the project example. Would you like to give it a try @ajhenry ? @samuelsycamore can help, or take over if you don't have the bandwidth to do it :) |
I think I can tackle this! |
Is this possibly actually just the same issue as noted here? #33017 The bug is related to portals not to tailwind I think. |
@smmccabe you linked the same issue, could you double check which issue you wanted to link here? :) |
Clearly not at my best on a Friday, #26767 |
@mnajdova Added a PR to update the docs and an example. You were right about the shadow dom details 馃槃 |
@ajhenry I'm working with nextjs and facing the same issue with autocomplete component. Can you guide me on how to fix it for nextjs? |
Duplicates
Latest version
Current behavior 馃槸
When using MUI style interoperability with tailwind and CRA/Next, we need to specify the
important
option in the tailwind config in order to correctly apply styles between the two frameworks.All components of the React tree should fall under the container they are spawned in
#root
/#__next
.The
Popover Menu
elements uses Portals under the hood and doesn't respect the React container and instead makes the container a child of thebody
element.The means that no tailwind styles can be applied to any Menu children and anything contained within that popover element.
Example Component
Generates the following DOM tree
And as we can see, the Menu component falls outside the
#__next
react containerExpected behavior 馃
The popover menu should be able to have styles applied to it correctly from other CSS frameworks like the rest of the components.
This may mean that it should be generated within the React container that spawned it
Steps to reproduce 馃暪
Steps:
Context 馃敠
When following the docs at MUI Tailwind Inoperability it says to specify
#__next
/#root
as the select to apply important to.However the Menu component gets generated as a child of the
body
element which falls outside of the React container. This breaks the cssimportant
selector and means tailwind cannot be applied to Menu childrenYour environment 馃寧
`npx @mui/envinfo`
Tested On Chrome
The text was updated successfully, but these errors were encountered: