Limited offer — lifetime access:$75$60
Rive · React

Using Rive icons in React

The useRive hook gives you the runtime. From there, firing the Hover and Clicked inputs on mouse events takes about 10 lines.

1

Install @rive-app/react-canvas

One package from npm.

JS
npm install @rive-app/react-canvas
2

Simple embed with RiveComponent

This is the quickest path. Point it at your .riv file and pass the state machine name. Unicorn Icons all use 'State Machine 1'.

JS
import { RiveComponent } from "@rive-app/react-canvas";

function RiveIcon() {
  return (
    <RiveComponent
      src="/your_animation.riv"
      stateMachines="State Machine 1"
      artboard="Main"
      autoplay
      style={{ width: 150, height: 150 }}
    />
  );
}
3

Trigger state machines with useRive

Use useRive when you need to fire the Hover or Clicked inputs from React event handlers. The hook gives you the live rive runtime.

JS
import { useRive, useStateMachineInput } from "@rive-app/react-canvas";

function RiveIcon() {
  const { rive, RiveComponent } = useRive({
    src: "/your_animation.riv",
    stateMachines: "State Machine 1",
    autoplay: true,
  });

  const hoverInput = useStateMachineInput(rive, "State Machine 1", "Hover");
  const clickInput = useStateMachineInput(rive, "State Machine 1", "Clicked");

  return (
    <div
      style={{ width: 150, height: 150 }}
      onMouseEnter={() => hoverInput && (hoverInput.value = true)}
      onMouseLeave={() => hoverInput && (hoverInput.value = false)}
      onClick={() => clickInput?.fire()}
    >
      <RiveComponent />
    </div>
  );
}

Common questions

What state machine names do Unicorn Icons use?

All icons use a state machine called State Machine 1 with boolean input Hover and trigger input Clicked.

RiveComponent vs useRive — which to use?

RiveComponent for simple embeds with no interaction. useRive when you need to fire state machine inputs from React events.

Does this work in Next.js?

Yes. Add "use client" to the component — Rive needs a browser canvas. Serve the .riv file from your public folder.

Get your animated icons

Browse icons ready for React — free to download.

Browse icons