Skip to content

useZIndex

Global z-index management hook. Maintains a monotonically increasing counter (starting at 1000) for coordinating layer ordering across multiple popup components.

Usage

ts
import { useZIndex } from 'see-u-ui'

const { currentZIndex, nextZIndex, releaseZIndex } = useZIndex()
const z = nextZIndex() // 1001

// With base z-index
const { nextZIndex: next } = useZIndex(2000)
next() // 2000

API

useZIndex(baseZIndex?)

ParamTypeDefaultDescription
baseZIndexnumberundefinedMinimum floor for the global counter

Returns:

PropertyTypeDescription
currentZIndexRef<number>Current z-index value
nextZIndex() => numberGet next incrementing z-index
releaseZIndex() => voidRelease instance (counter stays monotonic)
getCurrentZIndex() => numberRead current z-index

Liao ICP No. 2025070134