useHover
Custom hook that tracks whether a DOM element is being hovered over.
Installation
npx sse-tool add use-hover
npm install sse-hooks
Usage
import { useHover } from "./{hooks file}";
const buttonRef = useRef<HTMLButtonElement>(null);
const isHovered = useHover(buttonRef);
// Access the isHovered variable to determine if the button is being hovered over.
import { useHover } from "sse-hooks";
const buttonRef = useRef<HTMLButtonElement>(null);
const isHovered = useHover(buttonRef);
// Access the isHovered variable to determine if the button is being hovered over.
API
Parameters
| Name | Type | Description |
|---|---|---|
| elementRef | RefObject | The ref object for the DOM element to track. |
Return Value
Returns boolean.
A boolean value indicating whether the element is being hovered over.