useDelay
Commons
stable
Manages open/close delay timing for overlay components. Reads openDelay and closeDelay from IDelayProps and exposes runOpenDelay / runCloseDelay helpers that debounce state transitions. Each new call cancels any in-flight delay, preventing race conditions when hover enters and leaves quickly.
API
Signature
Full TypeScript signature sourced from the composable file.
Consumed interfaces
IDelayProps
API
Parameters
Input parameters accepted by this composable.
- propsrequiredIDelayProps
- Props object containing openDelay and closeDelay (number | string). Both are optional; missing values default to 0 (no delay).
- cb(value: boolean) => void
- Optional callback invoked with true when the open delay fires, false when the close delay fires. Use this to drive a reactive open state instead of awaiting the promise.
API
Return values
Properties and methods exposed by the composable return object.
- clearDelay
- Cancel the currently scheduled delay without triggering the callback.
- runOpenDelay
- Start the open delay. Cancels any previously scheduled delay. Resolves with true after props.openDelay ms and fires cb(true).
- runCloseDelay
- Start the close delay. Cancels any previously scheduled delay. Resolves with false after props.closeDelay ms and fires cb(false).
Usage
Examples
Ready-to-paste usage snippets.
Tooltip with open/close delay
Await the delay promise