How to Build an Interactive Button in Rive
An interactive button in Rive is a vector shape plus a state machine with three or four states (idle, hover, press, disabled). You design it once in the Rive editor, then developers drop in the exported .riv file and it responds to real input — no animation code written on the app side.
Why not just use CSS transitions?
For a simple color change, use CSS. Rive earns its place when the motion is complex: a checkbox that draws itself, a loader with rotating segments, a slider knob that squashes on drag. Anything where a keyframe timeline would need coordinated timing across several shapes.
The runtime file is the other argument. A .riv file with a few artboards usually lands between 20 and 120 KB, which is smaller than most icon fonts and far smaller than a Lottie JSON of similar complexity.
How do you set up the artboard in Rive?
- Create a new file and name the artboard something the dev will recognize —
PrimaryButton, notArtboard 1. - Draw the button background: a rounded rectangle with a fill and a slight shadow shape.
- Add the label as a text object bound to the artboard’s text run, so the dev can swap copy without editing the file.
- Group the shapes that move together. State machine conditions target whole objects, not individual paths.
- Set the artboard size to your real button size in pixels. Scaling after export blurs vectors less, but it changes hit areas.
Naming is the part everyone skips. Three months later the dev cannot tell which Artboard 3 is live.
How do you build the state machine?
Create a state machine on the artboard, then add layers: one for the button animation, one for the hover glow, one for the label shift.
Add these inputs:
hover— booleanpressed— booleandisabled— boolean
Then wire transitions. A transition needs a condition and an animation to play. Idle to Hover fires on hover == true. Hover to Press on pressed == true. Press to Hover on pressed == false. Add a fallback from any state to Disabled on disabled == true.
Two rules keep it clean. Give every transition a duration under 150ms for buttons — longer feels laggy on tap. And never leave a state without an exit, or the button will get stuck in it when the user releases outside the hit area.
How do you connect it to a web app?
Export as .riv runtime, then use the @rive-app/web package or the React wrapper.
import { useRive } from '@rive-app/react-canvas'
const { RiveComponent } = useRive({
src: '/button.riv',
stateMachines: 'ButtonState',
autoplay: true,
})
Then bind events on the wrapper element and call rive.stateMachineInputs('ButtonState') to set the boolean inputs on pointer enter, leave, and down.
The single most common integration bug: forgetting stateMachines: 'ButtonState'. Without it, the file loads and simply does nothing, which looks like the animation is broken.
How big does the file get?
Small, if you avoid a few habits. Thirty artboards is fine; thirty embedded raster images is not. Every imported PNG adds kilobytes and blocks the runtime from staying vector-crisp.
Aim for one artboard per component, shared artboards for repeated icons, and no embedded fonts beyond one weight per file. Past roughly 300 KB, split into multiple .riv files and load the ones a page needs.
What are Rive’s real limitations?
The editor has a learning curve. State machines are a different mental model from keyframe timelines, and the first afternoon is frustrating for anyone coming from After Effects.
Pricing also catches teams off guard. The free tier covers one editor with limits on file history; team plans run per-seat monthly, and the runtime license terms for certain game engines differ from web. Check which tier you need before shipping into a commercial product.
Finally, Rive is not a page-layout tool. It does not know about your DOM, your responsive breakpoints, or accessibility. Hit areas and ARIA labels remain the developer’s job.
Who should use Rive?
Product teams shipping a design system with meaningful micro-interactions. Game studios animating UI. Anyone replacing a pile of JSON Lottie exports with something that reacts to input.
Skip it if your needs are static illustrations, simple CSS transitions, or video-like storytelling — those are cheaper problems solved elsewhere.
Quick Summary
- One Rive file with a state machine replaces per-state animation code; a button usually exports under 120 KB.
- Three boolean inputs (hover, pressed, disabled) cover most button behaviour.
- Keep transitions under 150ms and give every state an exit transition.
- Pass
stateMachinesto the runtime or the file loads and does nothing. - Limits: steep editor learning curve, per-seat pricing, and no accessibility handling.
Feature list, supported runtimes, and licence tiers are on the Rive tool page.
