Hadi Pawar
Hadi Pawar

Reputation: 1126

Prevent Material-UI Dialog from applying inline styles to body

In the image below, you can see padding-right and overflow inline styles that have been added to the <body> element when the Dialog was opened.

enter image description here

How can I prevent Material-UI from adding those styles to the body element?

Upvotes: 2

Views: 1043

Answers (1)

Ryan Cogswell
Ryan Cogswell

Reputation: 81156

This functionality is part of Modal (used by Dialog) and is implemented here.

You can turn this off by adding the disableScrollLock prop to your Dialog.

Example:

<Dialog
      disableScrollLock
      onClose={handleClose}
      aria-labelledby="simple-dialog-title"
      open={open}
    >
  ...
</Dialog>

Edit Material demo

Documentation: https://material-ui.com/api/modal/#props

Upvotes: 4

Related Questions