use-hover

Detect if mouse is over given element
Import

Usage

Put mouse over me please
import { useHover } from '@mantine/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;
};