ClickAwayListener API
API reference docs for the React ClickAwayListener component. Learn about the props, CSS, and other APIs of this exported module.
Demos
Import
import ClickAwayListener from '@mui/material/ClickAwayListener';
// or
import { ClickAwayListener } from '@mui/material';
Learn about the difference by reading this guide on minimizing bundle size.
Listen for click events that occur somewhere in the document, outside of the element itself. For instance, if you need to hide a menu when people click anywhere else on your page.
Name | Type | Default | Description |
---|---|---|---|
children* | element | - | The wrapped element. |
onClickAway* | func | - | Callback fired when a "click away" event is detected. |
disableReactTree | bool | false | If |
mouseEvent | 'onClick' | 'onMouseDown' | 'onMouseUp' | 'onPointerDown' | 'onPointerUp' | false | 'onClick' | The mouse event to listen to. You can disable the listener by providing |
touchEvent | 'onTouchEnd' | 'onTouchStart' | false | 'onTouchEnd' | The touch event to listen to. You can disable the listener by providing |
Source code
If you did not find the information in this page, consider having a look at the implementation of the component for more detail.