Skip to content

useOverlay

Overlay/mask state management hook. Computes full-screen fixed overlay styles and handles show/hide lifecycle.

Usage

ts
import { ref } from 'vue'
import { useOverlay } from 'see-u-ui'

const show = ref(false)
const { visible, overlayStyle, handleClick } = useOverlay({
  show,
  opacity: ref(0.5),
  onClick: () => { show.value = false }
})

API

useOverlay(options)

ParamTypeDefaultDescription
options.showRef<boolean>Show/hide control
options.zIndexRef<number>-z-index
options.backgroundstring'var(--see-overlay-bg)'Background color
options.opacityRef<number>1Opacity
options.durationnumber300Duration (ms)
options.isAnimatedRef<boolean>trueEnable animation
options.onClick() => void-Click callback

Returns:

PropertyTypeDescription
visibleRef<boolean>Visibility state
overlayZIndexComputedRef<number>Computed z-index
overlayStyleComputedRef<CSSProperties>Overlay styles
handleClick() => voidClick handler

Liao ICP No. 2025070134