Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

182
Views
Position Material-UI Drawer component under Appbar

I'm creating a single-page application (Material-UI based) with an AppBar (+ ToolBar) and a Drawer. At the moment, the Drawer overlaps the AppBar and under no circumstances can I get the Drawer to move down, so it is basically positioned right under the AppBar.

I tried adding some padding, but this does not do anything. I'm using makeStyles for styling of most of the components, and I am wondering if it is even possible to position the Drawer below the AppBar.

Is there any way to position the drawer below the AppBar?

I have a lot of code, but the makeStyle function is simple:

const useStyles = makeStyles((theme) => ({
  root: {
    display: 'flex',
  },
  appBar: {
    zIndex: theme.zIndex.drawer + 1,
  },
  title: {
    flexGrow: 1,
  },
  toolbar: {
    display: 'flex',
    alignItems: 'center',
    justifyContent: 'flex-end',
    padding: theme.spacing(0, 1),
    ...theme.mixins.toolbar,
  },
  content: {
    flexGrow: 1,
    padding: theme.spacing(3),
  },
  drawer: {
    paddingTop: 30
  },
}));

and the main component (that includes the Drawer:

<div className={classes.root}>
        <AppBar position="absolute" >
          <Toolbar>  
            <Typography component="h1" variant="h6" noWrap className={classes.title}>
              x
            </Typography>
            <Switch checked={isDarkTheme} onChange={handleThemeSwitch}/>
            <WbIncandescentIcon />
          </Toolbar>
        </AppBar>
        <ServiceDrawer className={classes.drawer} 
        onOperationSelected={onOperationSelect} serviceList={services} onDrawerOpen={onDrawerOpen} onDrawerClose={onDrawerClose}> 
        </ServiceDrawer>
        <main className={classes.content}>
            <div className={classes.toolbar} />
            {selectedOperation && <Operation operation={selectedOperation}/>}
        </main>
    </div>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You need to set the variant of the Drawer to permanent so that it does not create an overlay over the current page, and put it inside the current app layout. Because the Drawer position is fixed, you also have to set the AppBar to fixed so they're on the same stacking context, and the z-index will be applied correctly, to put it in code:

<Drawer variant="permanent"
<AppBar position="fixed"

And finally the zIndex itself

appBar: {
  zIndex: theme.zIndex.drawer + 1
},

Codesandbox Demo

Reference

  • https://v4.mui.com/components/drawers/#clipped-under-the-app-bar
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!