Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

183
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda