v6.0.35

use-hover

Detect if mouse is over given element
Import

Usage

Put mouse over me please
import { useHover } from '@asuikit/hooks';
function Demo() {
const { hovered, ref } = useHover();
return (
<div ref={ref}>
{hovered ? 'I am hovered' : 'Put mouse over me please'}
</div>
);
}

Definition

function useHover<T extends HTMLElement = HTMLDivElement>(): {
ref: React.MutableRefObject<T>;
hovered: boolean;
};