useHover

Custom hook that tracks whether a DOM element is being hovered over.

Custom hook that tracks whether a DOM element is being hovered over.

Usage

import { useHover } from "@tilt-legal/cubitt-components/utilities/hooks";

const buttonRef = useRef<HTMLButtonElement>(null);
const isHovered = useHover(buttonRef);
// Access the isHovered variable to determine if the button is being hovered over.

API

Signature

declare function useHover<T extends HTMLElement = HTMLElement>(elementRef: RefObject<T>): boolean;

Parameters

ParameterTypeDescriptionDefault
elementRefRefObject&lt;T&gt;The ref object for the DOM element to track.-

Return Value

ValueTypeDescription
returnbooleanA boolean value indicating whether the element is being hovered over.

On this page