Skip to content

useHover ​

A hook that tracks whether the element is being hovered.

Code demonstration ​

API ​

javascript
const isHovering = useHover(target, {
  onEnter,
  onLeave,
  onChange,
})

Params ​

PropertyDescriptionTypeDefault
targetDOM element or ref() => Element | Element | JSX.Element-
optionsMore configOptions-

Options ​

PropertyDescriptionTypeDefault
onEnterCallback to be executed on mouse hover() => void-
onLeaveCallback to be executed on mouse leave() => void-
onChangeCallback to be executed on hover change(isHovering: boolean) => void-

Result ​

PropertyDescriptionType
isHoveringWhether the element is being hoveredReadonly<Ref<boolean>>

Source ​

Source · Document · Demo

Released under the MIT License.