I am trying to acheive the clipped under the app bar
style temporary drawer. But I can't seem to be able to set the z index on the temporary drawer.
The temporary drawer in material-ui has the z-index of the modal
component which is 1300
as mentioned in the issue I raised here https://github.com/mui-org/material-ui/issues/22562.
So, if I use the approach given in the documentation of setting the appbar zIndex to theme.zIndex.modal + 1
, I can get the 'clipped under the app bar` effect. But that would also mean that my appbar would be above all my modals. Which is not what I desire.
So, I wanted to set my temporary drawer to z-index of 1250
and my appbar's z-index to 1251
to get the desired effect without any side-effects.
I am trying to set the zIndex with makeStyles
hook as you can see in the sandbox and also the snippet below:
const useStyles = makeStyles((theme) => ({
appBar: {
zIndex: 1251
},
drawer: {
width: drawerWidth,
flexShrink: 0,
zIndex: 1250
},
drawerPaper: {
width: drawerWidth
}
}));
<AppBar position="fixed" className={classes.appBar}>
.
.
.
</AppBar>
<Drawer
className={classes.drawer}
open={true}
classes={{
paper: classes.drawerPaper
}}
>
.
.
.
</Drawer>
codesandbox: https://codesandbox.io/s/material-demo-forked-rq1fj?file=/demo.js