Skip to content

useScrollReveal

@hua-labs/hua/motion

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

tsx
const reveal = useScrollReveal({ threshold: 0.2 });

return (
  <div ref={reveal.ref} style={reveal.style}>
    Content reveals on scroll
  </div>
);

fadeIn
slideUp
slideLeft
scaleIn

thresholdnumber0.1Viewport intersection threshold (0-1)
rootMarginstring"0px"IntersectionObserver root margin
triggerOncebooleantrueOnly trigger animation once
durationnumber700Animation duration in milliseconds
motionType"fadeIn" | "slideUp" | "slideLeft" | "slideRight" | "scaleIn" | "bounceIn""fadeIn"Animation type on reveal
delaynumber0Animation delay in milliseconds
easingstring"ease-out"CSS easing function
onComplete() => void-Callback when reveal animation completes
onStart() => void-Callback when reveal animation starts
onStop() => void-Callback when animation is stopped
onReset() => void-Callback when animation is reset

refRefObject<T | null>Ref to attach to element
styleCSSPropertiesAnimated style object
isVisiblebooleanWhether element is in viewport
isAnimatingbooleanWhether animation is in progress
progressnumberAnimation progress (0-1)
start() => voidManually start reveal
stop() => voidStop animation
reset() => voidReset to hidden state

tsx
const reveal = useScrollReveal({
  motionType: "slideUp",
  delay: 200,
  easing: "ease-in-out",
});