THE MOTION FIELD GUIDE / INTERACTION DESIGN
How to make Lottie interactive
Connect a real input to playback: hover and click can start a segment, while scroll and cursor position can select a frame. Keep the product state in accessible HTML, load deliberately and provide a static reduced-motion experience.
Try the live demos ↗Start with the behavior, not the effect
An interactive Lottie animation responds to something meaningful: a pointer entering a control, a user completing a step, a scroll position, or a change in application state. The most useful starting point is a sentence: “When this happens, the interface should show that.” A checkmark might confirm a saved preference. A progress illustration might explain that a document is being processed. Those are different jobs and should not share the same trigger just because both can loop.
Write down the trigger, visual response, duration, interruption behavior and fallback before animating. Decide whether a repeated click restarts the sequence, reverses it, or is ignored while a task is pending. Then keep that rule consistent across mouse, touch and keyboard. The interactive Lottie showroom lets you compare eight small examples using original portfolio work. Treat them as a conversation about product behavior, rather than a prescription to animate every control.
Choose the smallest suitable implementation
For a single hover or click response, direct control through lottie-web can be enough. You create the player, wait for its DOMLoaded event, and attach the input handler. For a sequence of interactions, LottieFiles Interactivity provides cursor, scroll and chain modes. The showroom’s state example uses its chain mode to connect a click, playback completion and a reset. Its artwork is still an original Lottie JSON file.
A dotLottie state machine is a separate option, with state definitions and a compatible runtime. Do not tell a developer that a normal JSON export contains a state machine unless that was actually authored and delivered. The implementation affects integration, testing and maintenance. Choose it with the team that owns the product code, and pin the package version used in the handoff instead of relying on a changing latest URL.
| Need | Practical starting point | What to define |
|---|---|---|
| One hover response | lottie-web playback | Enter, leave and focus behavior |
| A reversible toggle | Button state + timeline direction | True/false state and fast repeats |
| A scroll sequence | Progress mapped to a frame | Start/end positions and fallback |
| Chained visual steps | LottieFiles Interactivity | Completion and input transitions |
| Packaged state behavior | dotLottie state machine | Compatible runtime and inputs |
Build a useful hover animation
A hover animation should help a visitor recognize a control or understand a possible action. The connect icon in the showroom is a short example: it plays when the pointer enters, when the button receives focus, or when the visitor taps it. Leaving the area pauses playback. The button remains a real HTML button, so it can receive keyboard focus without making the SVG renderer itself into an interactive element.
button.onpointerenter = () => player.goToAndPlay(0, true);This is the central interaction, not a complete installation script. It assumes an initialized player, a valid button reference and an animation that is ready. Add focus and click handling, decide what pointer leave does, and remove listeners when the component unmounts. If you attach a handler on every render without cleanup, one pointer event may eventually trigger several competing actions.
Keep toggles truthful
A like, checkbox, switch and menu button can all cause an animation, but their meanings differ. A like button can expose aria-pressed. A custom checkbox or switch needs its correct role and aria-checked state. A menu disclosure needs aria-expanded and a connection to the content it controls. Lottie adds feedback; it does not replace that semantic contract or the visible label.
Update the underlying product state independently of the animation. If a save fails, a beautiful success timeline must not be the only thing the user sees. In a real application, confirm success from the actual operation. The portfolio demo is intentionally a local visual interaction: it does not send a payment, enable audio or save a server-side setting. When commissioning a control, include its pending, success, error and disabled conditions in the brief.
player.setDirection(enabled ? 1 : -1); player.play();Reversing playback works best when the artwork was designed to travel both ways. If the timeline contains a long celebration, reversing the whole sequence may look awkward. A purpose-built enter segment and exit segment can be clearer. Ask for the frame ranges or named markers that the developer should use.
Map scroll to progress without taking over the page
A scroll-scrub animation uses position as its input. First decide the interval: for example, the point at which a section enters the viewport to the point at which it leaves. Normalize that interval to a value between zero and one, clamp it, then map it onto the animation’s available frames. The visible result should remain consistent if the visitor scrolls backwards, resizes the browser or jumps directly to an anchor.
player.goToAndStop(progress * (player.totalFrames - 1), true);Use a passive scroll listener to schedule one requestAnimationFrame update. Read layout deliberately and avoid changing the height of the same section while measuring it. Only seek visible animations. The SaaS scroll story uses three portfolio compositions for onboarding, dashboard interaction and confirmation. Each chapter has readable HTML copy, so the story remains understandable without motion.
Do not make scrolling a prerequisite for accessing essential information. A visitor may use keyboard navigation, a short screen, a browser search or a reduced-motion preference. Chapter buttons provide a direct route through the narrative, while the normal document retains its headings and links. The page should feel like a product explanation, not a test of how precisely somebody can operate a trackpad.
Give cursor-follow a second input
Cursor-driven motion can reveal depth or invite exploration, but there is no hover cursor on a phone. In the showroom, the pointer’s horizontal position selects a frame and gently offsets the sphere. A labeled range control exposes the same position to touch and keyboard users. That alternate control is part of the interaction design, not an afterthought added during accessibility testing.
Clamp the movement to the intended area, use a modest visual offset and avoid reading every pointer event as a reason to rebuild the SVG. A single scheduled frame is enough to apply the most recent position. Keep the animation from following the pointer outside its own demo unless a wider interaction is deliberate. When motion is reduced, retain the slider’s value and text response without moving the artwork.
Describe state transitions explicitly
The state-chain demo has three understandable steps: ready, working and confirmed. A click starts the sequence, completion advances it, and another click resets it. The library handles the interaction chain; visible text names the current state. This makes the mechanism easier to inspect than a loop which happens to resemble a loading process.
LottieInteractivity.create({ player, mode: "chain", actions: states });The states variable contains the agreed action definitions and frame segments. In a real product, a network response may need to control the transition instead of animation completion. Never advance from processing to success merely because a decorative timeline finished. Define timeout, retry and cancellation behavior with the application team, and decide which state should be restored when a visitor returns to a hidden browser tab.
Treat loading and cleanup as part of the design
A good interaction needs a useful first frame. Reserve the player’s dimensions before loading, display a representative poster and fetch the JSON near the moment it is needed. A library page with many examples should not run every composition simultaneously. Offscreen animation can consume CPU even when the visitor has already moved to another section.
Pause players when they leave the viewport and when the page becomes hidden. Destroy players and remove input listeners when their component is removed. If you load new artwork asynchronously, guard against an older request replacing the latest selected scene. The same principle applies to color previews: the most recent user choice should win, even when two requests finish in the opposite order.
Keep an error path. A missing file should leave a poster and a useful link, not a permanent loading message. Explain what is unavailable without disabling the rest of the page. For file size and runtime choices, see Lottie performance best practices and the format comparison.
Make reduced motion a complete experience
A prefers-reduced-motion setting is a request to limit unnecessary movement. On this site, the hero uses a static poster in that mode. The interactive examples keep their controls and text feedback while the visual artwork remains still. The scroll story becomes a readable sequence with static chapter previews. There is no essential instruction hidden in a moving layer.
Test the setting before loading the page and while the page is already open. A preference change should stop existing playback and restore the poster, not only affect players created later. For an application with longer sequences, a dedicated pause control can also be helpful. Keep decorative SVG content away from duplicate screen-reader announcements and let the HTML control describe the actual action.
Brief and test the interaction as a small product feature
A useful handoff includes the source artwork, the agreed JSON or dotLottie export, a poster, dimensions, frame rate, file size, interaction states and a short integration note. Include what happens on the first load, on a repeated click, on a failed request and when the visitor changes motion preferences. These details reduce guesswork between design and development.
For QA, use a mouse, touch simulation and the keyboard. Check a narrow viewport, a slow connection, a direct link to the section and a background tab. Confirm that controls still announce the correct state, buttons have usable hit areas, no player keeps running offscreen, and no error leaves the page stuck. Measure the actual composition in the actual page; a small icon export does not predict the cost of a complex illustration.
If you need a custom interactive Lottie animation, start with the screen and the user action. The estimator gives a planning range for animation work, while application integration is scoped from your framework and requirements. Explore Lottie animation services, compare the web animation workflow, or send a brief with the states your product needs.
Frequently asked questions
How do I make a Lottie animation interactive?
Load it with a compatible player, wait for the player to be ready, then connect a real input or application event to playback. For example, pointer entry can play a segment, a button can change direction, and scroll progress can select a frame.
Does a Lottie JSON file contain my product logic?
Usually the application owns the logic. A JSON animation describes the visual timeline; your code connects it to UI state. A dotLottie state machine is a different delivery approach and should be agreed explicitly.
Can I trigger Lottie on hover and still support phones?
Yes. Add a tap or button alternative, and make the same action available from keyboard focus or activation. A feature that requires a mouse hover alone is incomplete on touch devices.
How can I avoid scroll animation jank?
Keep the scroll listener passive, calculate progress once per animation frame, seek only visible players and keep the composition lightweight. Test the actual file and page on a phone instead of judging a desktop preview alone.
What happens with reduced motion?
Use a useful static preview and retain the meaning of the interface in HTML. Buttons still change state, success messages still appear and navigation still works. Avoid mapping scroll or cursor movement to decorative motion for those users.
Do these examples include a production license for the artwork?
No. They demonstrate original portfolio work and interaction patterns. A custom project supplies the agreed artwork, exports and rights. Public access to a preview is not permission to reuse a client asset.
Sources and implementation references
The behavior above is illustrated by this site’s own implementation. For the underlying APIs and runtime distinctions, consult the maintainers’ documentation:
