Skip to content
On this page

useHover

A hook that tracks whether the element is being hovered.

Code demonstration

API

const isHovering = useHover(target, {
  onEnter,
  onLeave,
  onChange,
})
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

SourceDocsDemo