Skip to content

useHoverMotion

@hua-labs/hua/motion

bash
npm install @hua-labs/hua
tsx
import { useHoverMotion } from "@hua-labs/hua/framework";

tsx
const hover = useHoverMotion({
  hoverScale: 1.05,
  hoverY: -2,
  duration: 200,
});

return (
  <div ref={hover.ref} style={hover.style}>
    Hover me for scale + lift effect
  </div>
);

Scale

Lift

Glow

durationnumber200Transition duration in milliseconds
easingstring"ease-out"CSS easing function
hoverScalenumber1.05Scale factor on hover
hoverYnumber-2Vertical offset on hover (px)
hoverOpacitynumber1Opacity on hover

refRefObject<T | null>Ref to attach to element
styleCSSPropertiesAnimated style with transform, opacity, transition
isHoveredbooleanWhether element is currently hovered
isVisiblebooleanVisibility state (always true)
isAnimatingbooleanWhether hover transition is in progress
progressnumberHover progress (0 or 1)
start() => voidProgrammatically activate hover state
stop() => voidStop animation
reset() => voidReset to unhovered state