useHover

Commons
stable

Tracks whether the host element is hovered via mouseenter/mouseleave events. Supports forced-on (hover=true) and IHoverState config objects for per-axis style overrides. Pairs with useColorEffect for theme-aware hover surfaces.

API

Signature

Full TypeScript signature sourced from the composable file.

typescript

Consumed interfaces

IHoverProps
IHoverState

API

Parameters

Input parameters accepted by this composable.

props
required
IHoverProps
Component props. Reads `props.hover` — accepts undefined/false (event-driven), true (forced on), or an IHoverState config object.
name
string
getCurrentInstanceName()
Component name prefix for the `{name}--hovered` class.

API

Return values

Properties and methods exposed by the composable return object.

isHover
True when the element is hovered (event-driven) or when forced via `hover=true` / `{ enabled: true }`.
hoverState
The IHoverState config object when the consumer passed one, undefined otherwise. Consumed by useStateEffect.
hoverClasses
Includes `{name}--hovered` when isHover is true.
onMouseenter
Bind to `@mouseenter` on the root element to activate event-driven hover tracking.
onMouseleave
Bind to `@mouseleave` on the root element to deactivate hover tracking.

Usage

Examples

Ready-to-paste usage snippets.

Component with hover color effect

vue

Forced hover (story / test)

vue