0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

MUI ModalコンポーネントにあるdisableScrollLockプロパティ

Posted at

業務の中で、MUIDialogコンポーネントを使用してダイアログを作成した際に、背後のコンテンツのスクロールを制御したいという状況がありました。その際に、disableScrollLockプロパティという便利なものがあったので記録します

概要

  • プロパティ名: disableScrollLock
  • 型:boolean
  • デフォルト:false

このプロパティは、DialogModal コンポーネントに対して true または false の値を設定することで使用できる。

使用例

下記の例では、disableScrollLock プロパティを true に設定しています。これにより、ダイアログが開いている間でも、ページの背景をスクロールできるようになります。

import React from 'react';
import Dialog from '@material-ui/core/Dialog';

function MyDialogComponent(props) {
  return (
    <Dialog open={props.isOpen} onClose={props.handleClose} disableScrollLock={true}>
      {/* ダイアログの内容 */}
    </Dialog>
  );
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?