Skip to content
Limited timeStarter is now $9 a month instead of $20.See plans
charmotion

How to Use an Animated Mascot in Cookie Consent & Privacy Prompts

By the Charmotion team · Updated · How we write guides

Cover illustration for the guide: How to Use an Animated Mascot in Cookie Consent & Privacy Prompts, with Charmotion demo characters

An animated mascot in a cookie consent banner should stay decorative: it waves once when the banner appears, shows neutral states while a choice saves, and never celebrates accept over reject. Build it as a .riv file driven by a mood number, load it after the buttons render, and respect reduced motion. Your consent tool still decides what loads.

Key takeaways

  • A mascot in a cookie consent banner is decoration, so it must never make accept look more rewarding than reject.
  • Map each banner moment to one mood number: wave once on show, idle while waiting, loading while saving.
  • Ship the mascot as a .riv file driven by a number input, and load it after the banner's buttons are on screen.
  • Honor prefers-reduced-motion and mark the canvas aria-hidden so the mascot never competes with the choices.
  • Test the banner at phone widths before release, because a mascot that covers a button undermines the choice more than any animation adds.

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.

Which mascot state fits each consent moment?

Each moment needs its own state, and the states should be quiet. The mood numbers below are fixed: idle 0, happy 1, wave 2, thinking 3, sad 4, loading 5, listening 6, talking 7, sleeping 8 and attention 9. Any Rive character with a numeric mood input can use the same map.

Banner momentMoodWhy
Banner first appears2 wave, then 0 idleOne greeting of about 3.0 seconds, then stillness
Waiting for a choice0 idleBreathing and blinking loop with no pull toward a button
Choice being saved5 loadingA short 1.2 second loop that signals work in progress
Choice saved0 idleNeutral after accept, reject or custom choices
Save failed4 sadPair with plain text that says what to do next
Settings panel open6 listeningOptional; shows the panel is waiting for input

Keep the mascot out of talking during the banner. A consent banner does not need lip movement, and talking suggests the mascot is reading the legal text aloud.

How do you build the mascot file for a banner?

A banner is a small space, so one .riv file is the right container. It holds the artboard, the animations and the state machine, and it loads straight into a web page with no video player or playback controls. Rive's runtimes are open source and play any .riv file, so the file is not tied to one banner tool.

You have two routes:

  • Design it in the Rive editor. Build a state machine with a number input named mood, map each state to a value from the table, and keep every loop short. The Rive Editor covers state machines and data binding. The setup is explained in Rive state machine inputs.
  • Generate it from one image. Charmotion turns one finished, front-facing character into one Rive file with a CharacterStateMachine and a mood number input, plus web code and transparent video copies. Its animations include wave (3.0 seconds), loading (1.2 seconds), attention (1.4 seconds) and sad (3.0 seconds), and idle is always included. Set the boolean accents to false if the banner should show no sparkles or exclamation marks. Credits and plans are on the Charmotion pricing page.

Either way, export for a live site on a paid Rive plan. Files exported on the free plan play a Rive splash screen, which a consent layer should not show. The details are in Is Rive free?

How do you wire the mascot to the banner in code?

The banner is ordinary HTML. The mascot is a canvas inside it, and a small script sets the mood number. The example uses the Rive web runtime from the @rive-app/canvas package, which loads its WASM module from the default CDN unless you host it yourself. Self-hosting is covered in Rive's WASM preloading docs.

Start with the markup. The canvas is marked decorative so screen readers skip it:

<div class='consent-banner' role='dialog' aria-labelledby='consent-title'>
  <canvas id='consent-mascot' width='160' height='160' aria-hidden='true'></canvas>
  <h2 id='consent-title'>Cookies on this site</h2>
  <p>We use analytics cookies only if you allow them.</p>
  <button>Accept</button> <button>Reject</button> <button>Settings</button>
</div>

Then the script. It skips every mood change when reduced motion is requested:

const reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
const mascot = new rive.Rive({
  src: '/assets/mascot.riv',
  canvas: document.getElementById('consent-mascot'),
  stateMachines: 'CharacterStateMachine',
  autoplay: true
});

function setMood(value) {
  if (reduceMotion) return;
  const inputs = mascot.stateMachineInputs('CharacterStateMachine');
  const mood = inputs.find(function (input) { return input.name === 'mood'; });
  if (mood) mood.value = value;
}

setMood(2);
setTimeout(function () { setMood(0); }, 3000);

Call setMood(5) when a choice starts saving, setMood(0) when the save finishes, and setMood(4) if it fails. Only call these after the banner's buttons are in the DOM. Keep the mood numbers in one constants object so the mapping lives in a single place.

How do you keep the mascot accessible and light?

A consent banner has to work for everyone who meets it, including people who turn off motion at the system level. Three checks cover most of the risk:

  • Reduced motion. When prefers-reduced-motion is set, the script above keeps the mascot on its first frame. Check that your CSS also drops any slide-in or fade on the banner itself. The broader pattern is in accessible animation and reduced motion.
  • Hidden from assistive technology. aria-hidden on the canvas keeps the decorative figure out of the accessibility tree. Focus should land on the dialog title or the first button, never on the mascot.
  • Small and fast. Keep the canvas around 120 to 160 pixels, and load the .riv after the banner text and buttons. The choice works even if the animation file is slow or fails.

On narrow screens, hide the mascot below a width you test rather than shrinking it over text. It must never cover the Accept, Reject, Settings or cookie policy links.

How do you test a mascot cookie banner before release?

Test the banner the way a visitor meets it, not in the editor preview. Work through this list on at least one phone, one laptop and Safari:

  1. Load the page on a throttled connection. The banner text and buttons should appear before the .riv finishes loading.
  2. Click each button and confirm the mascot shows the matching mood without covering the next screen.
  3. Turn on reduced motion in the operating system and reload. The mascot should stay still and the banner should not move.
  4. Check the banner at 320 pixels wide and at the largest text size your browser offers. No button or policy link should sit under the canvas.
  5. Open the file in the Rive file inspector to confirm the mood input exists with the expected name. The steps in how to preview a .riv file online cover state testing.

Ship when every row passes. A mascot that looks right on a desktop but blocks a button on a phone costs more trust than the animation earns.

How to add an animated mascot to a cookie consent banner

  1. Decide the mascot's role. Write down that the mascot is decorative. Give accept and reject the same size, contrast and placement, and never reward one option with a happy state.
  2. Map banner moments to moods. Use wave (2) once when the banner appears, idle (0) while waiting, loading (5) while a choice saves, and sad (4) if saving fails.
  3. Build or generate one .riv file. Create a file with a number input named mood, either in the Rive editor or from one character image. Export it for a live site on a paid Rive plan.
  4. Write the markup. Render the banner text and buttons first, and mark the canvas aria-hidden so assistive technology skips it.
  5. Wire setMood with a reduced-motion check. Load the .riv with the Rive web runtime, skip mood changes when prefers-reduced-motion is set, and return to idle after the wave ends.
  6. Test before release. Check slow connections, phone widths, reduced motion, each button and the mood input name in the Rive file inspector before publishing.

Frequently asked questions

Does a mascot change whether a cookie consent is valid?

The mascot is not a consent mechanism and does not record a choice. Whether a banner gives valid consent depends on its wording, the options it offers and what loads before a choice, which is a matter for your legal and privacy review. Keep the mascot neutral so it adds no pressure in either direction.

Can I use a transparent video instead of a Rive file?

You can, but video needs more than one format. Chromium-based browsers and Firefox display transparent WebM, while Safari has been reported to ignore VP9 alpha, so a HEVC alpha .mov fallback is usually needed. A .riv file avoids that split, and Rive's runtimes are open source and play any .riv file.

Does Rive provide a cookie banner template?

Rive does not document a cookie banner template as of December 2026. The banner is ordinary HTML and CSS, and the .riv file only supplies the animated figure inside a canvas.

Sources

Related guides