I would like to disable all of the browser rules that are exported when MUI is compiled
:
So I would like to see:
{
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: justify;
-webkit-justify-content: space-between;
justify-content: space-between;
-webkit-align-items: flex-start;
-webkit-box-align: flex-start;
-ms-flex-align: flex-start;
align-items: flex-start;
}
This
{
display: flex;
justify-content: space-between;
align-items: flex-start;
}
I cannot see a way to do this with MUI4 or MUI5.
import React from 'react'
import { styled } from '@mui/material'
const ChildContainer = styled('div')`
display: flex;
justify-content: space-between;
align-items: flex-start;
`
export const TopNav: React.FC = ({ children, ...props }) => {
return (
<ChildContainer data-name="ChildContainer">{children}</ChildContainer>
)
}
export default TopNav
You can control this using Emotion's CacheProvider component by providing it with a cache that does not leverage the prefixer stylis plugin. Below is a working example that allows you to toggle back and forth between including the vendor prefixes or not.
import React from "react";
import { CacheProvider } from "@emotion/react";
import createCache from "@emotion/cache";
import { styled } from "@mui/material/styles";
import Button from "@mui/material/Button";
import { prefixer } from "stylis";
const StyledDiv = styled("div")`
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: flex-start;
`;
const cacheNoPrefixer = createCache({
key: "noprefixer",
stylisPlugins: []
});
const cacheWithPrefixer = createCache({
key: "prefixer",
stylisPlugins: [prefixer]
});
export default function App() {
const [includePrefixer, setIncludePrefixer] = React.useState(false);
return (
<CacheProvider
value={includePrefixer ? cacheWithPrefixer : cacheNoPrefixer}
>
<StyledDiv>
Including Prefixing: {JSON.stringify(includePrefixer)}
<Button onClick={() => setIncludePrefixer(!includePrefixer)}>
Toggle Prefixing
</Button>
</StyledDiv>
</CacheProvider>
);
}
Related answers:
CacheProvider)