# @biggerpixel/use-on-click-outside

> Custom React Hook used to detect clicks outside of a specified element.

Latest version **1.0.0** (published 2022-10-11) · ISC license · 0 weekly downloads

## Install

```sh
npm install @biggerpixel/use-on-click-outside
pnpm add @biggerpixel/use-on-click-outside
yarn add @biggerpixel/use-on-click-outside
bun add @biggerpixel/use-on-click-outside
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2022-10-11 |
| First published | 2022-10-11 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | simonalmers |

## Links

- npm: https://www.npmjs.com/package/@biggerpixel/use-on-click-outside
- Repository: https://github.com/BiggerPixel/useonclickoutside
- Homepage: https://github.com/BiggerPixel/useonclickoutside#readme
- Issues: https://github.com/BiggerPixel/useonclickoutside/issues
- npm.io page: https://npm.io/package/@biggerpixel/use-on-click-outside

## Recent versions

- 1.0.0 (latest) — 2022-10-11

## README

# use-on-click-outside

## Usage

---

```
npm i @biggerpixel/use-on-click-outside
```

```typescript
import React, { useRef } from 'react';
import useBoolState from '@biggerpixel/use-bool-state';
import useOnClickOutside from '@biggerpixel/use-on-click-outside';

const Component = () => {
  const elementWrapper = useRef<HTMLDivElement>(null);
  const [isOpen, toggleIsOpen] = useBoolState(false);

  useOnClickOutside(elementWrapper, toggleIsOpen);

  return (
    isOpen && (
      <div ref={elementWrapper}>
        <h2>Content!</h2>
        <p>(Click outside to close)</p>
      </div>
    )
  );
};

export default Component;
```

---
_Source: https://npm.io/package/@biggerpixel/use-on-click-outside · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
