Files
grafana/packages/grafana-ui/src/components/ClickOutsideWrapper/ClickOutsideWrapper.mdx
Alex Khomenko 2a2992b04d Grafana-UI: Add docs for ClickOutsideWrapper (#27429)
* Grafana-UI: Add docs and story for ClickOutsideWrapper

* Grafana-UI: Update comments

* Grafana-UI: expand usage

* Grafana-UI: Tweak docs
2020-09-08 10:34:27 +03:00

19 lines
679 B
Plaintext

import { Meta, Props } from '@storybook/addon-docs/blocks';
import { ClickOutsideWrapper } from './ClickOutsideWrapper';
<Meta title="MDX|ClickOutsideWrapper" component={ClickOutsideWrapper} />
# ClickOutsideWrapper
A wrapper component that detects clicks outside of the elements by attaching event listener to `window` or `document` objects.
Useful for components that require an action being triggered when a click outside has occurred, for example closing an overlay or popup.
# Usage
```jsx
<ClickOutsideWrapper onClick={() => console.log('Clicked outside')}>
<div style={{width: '300px'}}>Container</div>
</ClickOutsideWrapper>
````
<Props of={ClickOutsideWrapper}/>