# detect-element-overflow

> A function that tells you whether a given element is overflowing its container or not. Useful for creating dropdowns and tooltips.

Latest version **2.0.0** (published 2025-03-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install detect-element-overflow
pnpm add detect-element-overflow
yarn add detect-element-overflow
bun add detect-element-overflow
```

## Health

**Score 55/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; has provenance; high quality score.

Warnings: low downloads.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2025-03-20 |
| First published | 2017-09-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 27 |
| Author | Wojciech Maj |
| Maintainers | wojtekmaj |
| Keywords | collision, collision-detection, position |

## Links

- npm: https://www.npmjs.com/package/detect-element-overflow
- Repository: https://github.com/wojtekmaj/detect-element-overflow
- Homepage: https://github.com/wojtekmaj/detect-element-overflow#readme
- Issues: https://github.com/wojtekmaj/detect-element-overflow/issues
- Funding: https://github.com/wojtekmaj/detect-element-overflow?sponsor=1
- npm.io page: https://npm.io/package/detect-element-overflow

## Recent versions

- 2.0.0 (latest) — 2025-03-20
- 1.4.2 — 2023-10-18
- 1.4.1 — 2023-05-29
- 1.4.0 — 2023-05-29
- 1.3.1 — 2023-02-02
- 1.3.0 — 2023-01-10
- 1.2.0 — 2019-11-03
- 1.1.1 — 2017-12-18
- 1.1.0 — 2017-09-10
- 1.0.0 — 2017-09-06
- 0.0.1-alpha — 2017-09-05

## README

[![npm](https://img.shields.io/npm/v/detect-element-overflow.svg)](https://www.npmjs.com/package/detect-element-overflow) ![downloads](https://img.shields.io/npm/dt/detect-element-overflow.svg) [![CI](https://github.com/wojtekmaj/detect-element-overflow/actions/workflows/ci.yml/badge.svg)](https://github.com/wojtekmaj/detect-element-overflow/actions)

# Detect-Element-Overflow

A function that tells you whether a given element is overflowing its container or not. Useful for creating dropdowns and tooltips.

## tl;dr

- Install by executing `npm install detect-element-overflow` or `yarn add detect-element-overflow`.
- Import by adding `import detectElementOverflow from 'detect-element-overflow'`.
- Do stuff with it!
  ```ts
  const collisions = detectElementOverflow(child, parent);
  ```

## User guide

Detect-Element-Overflow returns an object with getter functions described below.

| Attribute name | Description                                                                                                                                                         | Example values |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------- |
| collidedTop    | Whether or not the child element collided with the top parent's border.                                                                                             | `true`         |
| collidedBottom | Whether or not the child element collided with the bottom parent's border.                                                                                          | `true`         |
| collidedLeft   | Whether or not the child element collided with the left parent's border.                                                                                            | `true`         |
| collidedRight  | Whether or not the child element collided with the right parent's border.                                                                                           | `true`         |
| overflowTop    | How many pixels of the child have crossed the top parent's border. Negative values specify how many pixels are between the child and the top parent's border.       | `20`, `-15`    |
| overflowBottom | How many pixels of the child have crossed the bottom parent's border. Negative values specify how many pixels are between the child and the bottom parent's border. | `20`, `-15`    |
| overflowLeft   | How many pixels of the child have crossed the left parent's border. Negative values specify how many pixels are between the child and the left parent's border.     | `20`, `-15`    |
| overflowRight  | How many pixels of the child have crossed the right parent's border. Negative values specify how many pixels are between the child and the right parent's border.   | `20`, `-15`    |

## License

The MIT License.

## Author

<table>
  <tr>
    <td >
      <img src="https://avatars.githubusercontent.com/u/5426427?v=4&s=128" width="64" height="64" alt="Wojciech Maj">
    </td>
    <td>
      <a href="https://github.com/wojtekmaj">Wojciech Maj</a>
    </td>
  </tr>
</table>

---
_Source: https://npm.io/package/detect-element-overflow · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
