useMouse
@hua-labs/hua/motion
bash
npm install @hua-labs/huatsx
import { useMouse } from "@hua-labs/hua/framework";tsx
const { x, y, isOver } = useMouse();
return (
<div className="relative w-64 h-64 border">
{isOver && (
<div
className="absolute w-4 h-4 bg-primary rounded-full"
style={{ left: x, top: y, transform: 'translate(-50%, -50%)' }}
/>
)}
</div>
);| targetRef | RefObject<HTMLElement | null> | - | Target element ref (defaults to window) |
| throttle | number | 0 | Throttle interval in milliseconds |
| x | number | Mouse X position (viewport coordinates) |
| y | number | Mouse Y position (viewport coordinates) |
| elementX | number | Relative X position within target (0-1) |
| elementY | number | Relative Y position within target (0-1) |
| isOver | boolean | Whether mouse is over the target |