2

I am using Material UI Snackbar in a component, but the Snackbar shows up at the bottom of the page and isn't fixed so user will have to scroll to the bottom to see it.

<Snackbar>
  open={open}
  autoHideDuration={6000}
  onClose={handleClose}
>
  <Alert onClose={handleClose} severity="error">
    There was an error signin up. Please  try again!
  </Alert>
</Snackbar>

Here is the picture:

Snakbar

Mosh Feu
  • 28,354
  • 16
  • 88
  • 135
Victor Whyte
  • 80
  • 2
  • 8

1 Answers1

0

By nature <Snackbar /> sticks to bottom by position: fixed.

Maybe one of its parents breaks its fixed position, for example by having transform or will-change: transform.

<div style={{ willChange: "transform" }}>
  <Snackbar open={open} onClose={handleClose}>
    <Alert onClose={handleClose} severity="error">
      There was an error signin up. Please try again!
    </Alert>
  </Snackbar>
</div>

https://codesandbox.io/s/material-demo-forked-gvlmk?file=/demo.js


More info about what breaks position: fixed:

Mosh Feu
  • 28,354
  • 16
  • 88
  • 135