How to Add an Animated Mascot to Developer Tools, CLI & API Docs
By the Charmotion team · Updated · How we write guides

Add one animated mascot to developer tools and API documentation by exporting a single .riv file, mapping a few states such as idle, loading, success and error to real events, and embedding it with a small runtime. Keep it out of code samples and reference tables, and make it easy to skip.
Key takeaways
- Build the mascot as one .riv file with a few named states, then reuse it across docs pages, tool dashboards and changelogs.
- Tie each state to a real event such as a build finishing, a request failing or a page loading, not to decoration.
- Keep the mascot out of code samples, reference tables and anything a developer copies.
- Test each state in Storybook so a redesign cannot break the mascot without anyone noticing.
- Keep the animation small, quiet and skippable so readers reach the reference quickly.
Already have a character or logo? See examples in real app screens: splash, onboarding, loading and empty-state screens, with the animation that plays in each.
Where should an animated mascot go in developer docs and tools?
A mascot earns its place on pages where a person is waiting, learning or recovering from a problem. It does not belong in the reference text, in code samples or in anything a developer copies. This guide covers how to add an animated mascot to developer tools and API documentation so that it helps the reader and stays out of the way of the content.
| Surface | Good use | Keep it out |
|---|---|---|
| Docs landing page | A small greeting near the title, with idle and wave | Above the fold on reference pages |
| Getting-started guide | Loading while a sample project builds, success at the end | Inside every code block |
| Dashboard empty state | Invites the first API key or first project | Pages that already show an error |
| 404 or broken link page | Sad state with a link back to search | Nothing else; keep the error text plain |
| Changelog or status page | Happy state for a release, once per page | Each entry in a long list |
A command-line tool is different. A terminal prints text and cannot load a .riv file, because Rive's runtimes play files in web, mobile and game apps. Put the mascot on the web page the CLI links to, in the docs site or in a companion dashboard, and keep the terminal output plain and easy to copy.
Tools with a web console are the strongest fit. An API key page, a deployment list or a webhook log can each show one mascot state tied to what just happened, so the mascot carries information rather than decoration. For onboarding flows and empty states in more detail, see how to add a mascot to onboarding and empty states. A marketing site on a website builder has its own steps, covered in how to add an animated mascot to Squarespace.
Which mascot states does a developer product need?
Start with four states. Each one should answer a question the reader already has: is it working, did it finish, did it fail, or what should I do next. Name the states after the events in your code so the mapping stays readable.
| State | When it plays | Example in a developer product |
|---|---|---|
| idle | Nothing is running | Docs landing page greeting that loops slowly |
| loading | A request, build or sync is running | Waiting for a test run to finish |
| success | The last action finished | API key created, deployment live |
| error | The last action failed | Webhook returned an error, broken link |
Add a fifth state, such as listening or thinking for an AI assistant in the docs, only if a page needs it. Every extra state is one more thing to design, test and keep on brand.
Use one state input in the file and set it from one place in your code. The event names below are examples; your product will have its own.
const stateFor = { 'build.started': 'loading', 'build.passed': 'success', 'build.failed': 'error' };Keep the names in the file and in the mapping identical. When a designer renames a state, the change is then one line in one file, not a search through every page.
How do you embed the mascot in a docs page without slowing it down?
Treat the mascot as a fixed-size box that loads after the text. A reader should see the title and the first paragraph before any Rive code runs.
- Export one .riv file from the Rive editor with the artboard and state machine for the mascot. Free-plan exports play a Rive splash screen, while paid plans export without it, so check whether Rive's free plan fits your release before you publish.
- Host the file next to the docs, under a path your build can cache, rather than in a bucket you do not control.
- Reserve the space with a fixed width and height so the layout does not jump when the mascot appears. This matters for page stability; see hero animation and Core Web Vitals.
- Mount it late. Render the component only after the first paint, or when its box enters the viewport.
On a React docs site, Rive's React wrapper is the usual starting point. Its useRive hook loads the file and returns a component to render. Wrap the component in an element with the class docs-mascot, and set that class's fixed width and height in your stylesheet. Replace the state machine name with the one in your file.
import { useRive } from '@rive-app/react-canvas';
export function DocsMascot() {
const { RiveComponent } = useRive({
src: '/mascot.riv',
stateMachines: 'State Machine 1',
autoplay: true,
});
return <RiveComponent className="docs-mascot" />;
}Rive recommends this wrapper for most apps unless a WebGL renderer is needed. For a Next.js docs site, see how to use Rive in React and Next.js. If you want control over caching or the size of the runtime download, Rive's documentation covers loading and hosting the WASM file yourself.
How do you test each mascot state with Storybook?
Storybook is a free, open source workshop for building UI components in isolation. If your docs site or dashboard uses React, Vue, Angular or Svelte, you can give the mascot component one story per state. A story records how the component looks in that state, and the stories double as documentation for whoever maintains the page.
Storybook's official docs list React (with Vite or Webpack), Vue with Vite, Angular, Svelte with Vite, Preact with Vite and Next.js with Vite among supported frameworks. A story for each state can be as short as this, assuming the component takes a state prop:
export default { title: 'Docs/Mascot', component: DocsMascot };
export const Loading = { args: { state: 'loading' } };
export const ErrorState = { args: { state: 'error' } };Three kinds of test cover the mascot:
- Interaction tests are written inside a story and can be previewed and debugged in the Interactions panel. They can also run through the Vitest addon for local runs or CI.
- Snapshot tests render a component in a given state, save its DOM and compare it with a previous baseline. Storybook's docs say visual tests are usually the better fit for UI components.
- Visual tests compare the rendered pixels of each story against known baselines. The docs say running them sends stories to the cloud to take snapshots, so check that against your privacy rules before you turn it on.
Rive animations play over time, so a pixel snapshot can differ between runs. Capture a static poster image for each state, or stub the animation in tests. Storybook has no feature specific to character or mascot animation, so your coverage is only as good as the states you choose to capture.
How do you keep a mascot from getting in the way?
Developers open docs to finish a task. Four rules keep the mascot useful rather than distracting.
- Respect reduced motion. Check the prefers-reduced-motion media query and show the static poster instead of a looping animation.
- Say the state in text. Give the mascot an accessible label such as "Build running", and keep the status on the page itself, not only inside the animation.
- Keep loops quiet. Let idle loop slowly and play one-shot states such as success once, then settle.
- Make it dismissible. Remember the choice so a returning reader does not see the mascot again on every visit.
For more on motion settings and WCAG, see accessible animation, reduced motion and WCAG. Put the mascot on the page only after you know what the reader must do next, because a mascot that competes with a code sample costs more trust than it earns.
Can Charmotion make the mascot file for you?
Charmotion is our product. If you have one finished character image and no motion designer, Charmotion animates it and returns one Rive (.riv) file. You choose the animations you need from launch, happy, wave, loading, thinking, sad, listening, talking, sleeping and attention, and idle is included free.
The file holds a CharacterStateMachine with a number input named mood, so your event mapping can use these fixed numbers: idle 0, happy 1, wave 2, thinking 3, sad 4, loading 5, listening 6, talking 7, sleeping 8, attention 9. Characters have no one-shot triggers, so show a success with happy and an error with sad, which matches the four-state table above.
Web, React and SwiftUI code, a README and transparent poster images come with the file. The PNG to Rive page shows the file format, and the pricing page lists current plans. Whichever tool makes the file, the code in this guide works with any .riv that has a number input for the state.
How to add an animated mascot to developer tools and API documentation
- Choose the surface. Pick one page where a reader waits, learns or recovers, such as the docs landing page, a getting-started guide, a dashboard empty state or the 404 page. Keep reference text and code samples free of the mascot.
- Design four states. Define idle, loading, success and error, each tied to one event in your product. Add a fifth state only if a page needs it.
- Export one Rive file. Build the states in the Rive editor as one .riv file with a state machine, and export it on a paid plan if you need output without the splash screen.
- Embed it lazily. Reserve a fixed-size box, load the file with the runtime for your framework after the text renders, and show the static poster when reduced motion is on.
- Test every state. Write one Storybook story per state, add interaction or visual tests, and run them in CI so a redesign cannot break the mascot unnoticed.
Frequently asked questions
Can a mascot appear in a GitHub README?
A .riv file does not play in a README, so use an animated GIF or a static image there and keep the interactive version on the docs site. Check GitHub's own documentation for the current image rules before you publish.
Do I need Storybook to add an animated mascot?
No. Storybook is most useful when a mascot has many states or appears in several components, because each state becomes a story you can review and test. A single greeting on a docs page can ship without it. Storybook is free and open source, so the real cost is the time to write and maintain the stories.
Will an animated mascot hurt search ranking on docs pages?
Not if the page text is in the HTML and the mascot loads after it. Keep the component off the critical path, reserve its space and keep the file small. Your docs should read well without the mascot, which also helps screen readers and readers with scripts turned off.
Does the same .riv file work in different frameworks?
Rive's runtimes play the same .riv file across web and mobile platforms, so the file does not need to change when you move between a docs site and an app. Check the runtime documentation for your framework before you start, because each wrapper has its own setup steps.
Sources
- Rive Editor, Rive
- Rive React runtime (@rive-app/react-canvas), Rive
- Rive WASM runtime and preloading, Rive
- Storybook documentation, Storybook
- Interaction testing in Storybook, Storybook
- Visual testing in Storybook, Storybook