# dom-zindex

> Web common z-index style management

Latest version **1.0.7** (published 2026-05-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install dom-zindex
pnpm add dom-zindex
yarn add dom-zindex
bun add dom-zindex
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.0.7 |
| Published | 2026-05-26 |
| First published | 2023-08-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 31.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 11 |
| Author | Xu Liangzhan |
| Maintainers | x-extends |
| Keywords | z-index, zindex |

## Links

- npm: https://www.npmjs.com/package/dom-zindex
- Repository: https://github.com/x-extends/dom-zindex
- Homepage: https://github.com/x-extends/dom-zindex/
- Issues: https://github.com/x-extends/dom-zindex/issues
- npm.io page: https://npm.io/package/dom-zindex

## Recent versions

- 1.0.7 (latest) — 2026-05-26
- 1.0.6 — 2024-09-10
- 1.0.5 — 2024-08-26
- 1.0.4 — 2024-05-24
- 1.0.3 — 2024-05-24
- 1.0.2 — 2024-04-23
- 1.0.1 — 2023-09-20
- 1.0.0 — 2023-08-27
- 0.5.0 — 2023-08-25
- 0.4.0 — 2023-08-21
- 0.3.0 — 2023-08-20
- 0.2.0 — 2023-08-20
- 0.1.0 — 2023-08-20
- 0.0.1 — 2023-08-02

## README

# z-index Manager

English | [简体中文](README.zh-CN.md)  

[![gitee star](https://gitee.com/x-extends/dom-zindex/badge/star.svg?theme=dark)](https://gitee.com/x-extends/dom-zindex/stargazers)
[![gitcode star](https://gitcode.com/x-extends/dom-zindex/star/badge.svg)](https://gitcode.com/x-extends/dom-zindex/stargazers)
[![npm version](https://img.shields.io/npm/v/dom-zindex.svg?style=flat-square)](https://www.npmjs.com/package/dom-zindex)
[![gzip size: JS](http://img.badgesize.io/https://unpkg.com/dom-zindex/dist/index.umd.min.js?compression=gzip&label=gzip%20size:%20JS)](https://unpkg.com/dom-zindex/dist/index.umd.min.js)
[![npm downloads](https://img.shields.io/npm/dm/dom-zindex.svg?style=flat-square)](http://npm-stat.com/charts.html?package=dom-zindex)
[![issues](https://img.shields.io/github/issues/x-extends/dom-zindex.svg)](https://github.com/x-extends/dom-zindex/issues)
[![pull requests](https://img.shields.io/github/issues-pr/x-extends/dom-zindex.svg)](https://github.com/x-extends/dom-zindex/pulls)
[![npm license](https://img.shields.io/github/license/mashape/apistatus.svg)](LICENSE)

Web common z-index style management.

## Browser Support

![IE](https://raw.github.com/alrra/browser-logos/master/src/archive/internet-explorer_7-8/internet-explorer_7-8_48x48.png) | ![Edge](https://raw.github.com/alrra/browser-logos/master/src/edge/edge_48x48.png) | ![Chrome](https://raw.github.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png) | ![Firefox](https://raw.github.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png) | ![Opera](https://raw.github.com/alrra/browser-logos/master/src/opera/opera_48x48.png) | ![Safari](https://raw.github.com/alrra/browser-logos/master/src/safari/safari_48x48.png)
--- | --- | --- | --- | --- | --- |
7+ ✔ | 80+ ✔ | 44+ ✔ | 40+ ✔ | 60+ ✔ | 6+ ✔ |

## Installing

```shell
npm install dom-zindex
```

## CDN

package gzip <= 900B

```HTML
<script src="https://unpkg.com/dom-zindex"></script>
```

## Example 1

```javascript
import domZIndex from 'dom-zindex'

// Gets the largest z-index on the page.
domZIndex.getMax()

// Set main current z-index.
domZIndex.setCurrent(1000)

// Get main current z-index.
domZIndex.getCurrent() // 1000

// Get main next z-index.
domZIndex.getNext() // 1001

// Get subordinate current z-index, the secondary z-index will always be greater than the primary z-index.
domZIndex.getSubCurrent() // 2001

// Get subordinate next z-index.
domZIndex.getSubNext() // 2002
```

## Example 2

```javascript
import domZIndex from 'dom-zindex'

// If the incoming z-index is less than global, the next one is automatically fetched.
let currZIndex1 = 888
currZIndex1 = domZIndex.getCurrent(currZIndex1) // 1000

// If the z-index is greater than the global value, the value is returned.
let currZIndex2 = 2000
currZIndex2 = domZIndex.getCurrent(currZIndex2) // 1500
```

## Css var

* Built-in following variables
  * ```--dom-main-z-index``` 等于 ```getCurrent```()
  * ```--dom-sub-z-index``` 等于 ```getSubCurrent```()

```css
.my-popup {
  z-index: var(--dom-main-z-index);
}
.my-msg {
  z-index: var(--dom-sub-z-index);
}
```

## Contributors

Thank you to everyone who contributed to this project.

[![dom-zindex](https://contrib.rocks/image?repo=x-extends/dom-zindex)](https://github.com/x-extends/dom-zindex/graphs/contributors)

## License

[MIT](LICENSE) © 2019-present, Xu Liangzhan

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