Skip to content

useGradient

@hua-labs/hua/motion

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

tsx
const gradient = useGradient({
  colors: ["#ff0080", "#7928ca", "#0070f3"],
  autoStart: true,
});

return (
  <div style={gradient.style} className="h-64 rounded-lg">
    Animated Gradient Background
  </div>
);

colorsstring[]["#60a5fa", "#34d399", "#fbbf24", "#f87171"]Array of gradient colors
durationnumber6000Animation cycle duration in milliseconds
direction"horizontal" | "vertical" | "diagonal""diagonal"Gradient direction
sizenumber300Background size percentage
easing"linear" | "ease-in-out" | "ease-in" | "ease-out""ease-in-out"Animation easing function
autoStartbooleanfalseStart gradient animation automatically

refRefObject<T | null>Ref to attach to element
styleCSSPropertiesStyle with background gradient and animation
isVisiblebooleanVisibility state
isAnimatingbooleanWhether gradient is animating
progressnumberAnimation progress (0-1)
start() => voidStart gradient animation
pause() => voidPause animation
resume() => voidResume paused animation
stop() => voidStop animation
reset() => voidReset to initial state