Learn how to integrate lottie animations into your react application effortlessly.
Install rive react canvas dependency from npm
npm install @rive-app/react-canvas
Import animated icon json file in your component
import { RiveComponent } from "@rive-app/react-canvas";
function LottieIcon() {
return (
<RiveComponent
src="/your_animation.riv"
stateMachines="State Machine 1" // Clicked , Hover
artboard="Main"
autoplay
style={{ width: 150, height: 150 }}
/>
);
}
import { useRive } from "@rive-app/react-canvas";
const { rive, RiveComponent } = useRive({
src: "/your_animation.riv",
stateMachines: "State Machine 1", // Clicked , Hover
autoplay: true,
});
useEffect(() => {
const input = rive?.stateMachineInputs("State Machine 1").find(i => i.name === "Trigger");
input?.fire();
}, [rive]);
Find free animations at Unicornicons.