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

Building a Transparent Floating AI Assistant Mascot in Electron and Tauri with Rive

By the Charmotion team · Updated · How we write guides

Cover illustration for the guide: Building a Transparent Floating AI Assistant Mascot in Electron and Tauri with Rive, with Charmotion demo characters

Build it with a transparent, frameless, always-on-top window in Electron (transparent: true in BrowserWindow) or Tauri (transparent: true in tauri.conf.json), load a Rive .riv file into a canvas inside that window, and drive a number input named mood from your assistant's state. Keep the window sized to the mascot, because transparent areas still block clicks.

Key takeaways

  • Electron and Tauri both show a web page in a window, so one Rive .riv file runs in either shell.
  • Set transparent to true, remove the window frame and keep the window no larger than the mascot.
  • Map assistant states such as thinking, talking and listening to a mood number input.
  • Use transparent WebM on Chromium-based webviews and transparent HEVC MOV on WebKit.
  • A shipped mascot needs a paid Rive plan to export .riv files without a splash screen.

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.

What does a floating AI assistant mascot need from the desktop shell?

This guide shows how to build an Electron or Tauri floating AI assistant mascot with Rive. The pattern is the same in both shells: a small transparent window holds a canvas, the canvas plays a .riv file, and the assistant's state changes a number input inside that file.

Three requirements shape the build:

  • A transparent window. Only the character should be visible, so the window background and the Rive artboard both need no fill.
  • A small window. Electron's custom window styles guide states that transparent windows cannot be clicked through in the transparent area. The window should cover the mascot and little else.
  • One state source. The assistant's state (listening, thinking, talking) has to reach the mascot. Where that happens depends on the shell, as covered in the bridge section below.

Electron embeds Chromium and Node.js in each app, so the mascot runs in Chromium. Tauri uses the operating system's own webview instead: WebView2 on Windows, WKWebView on macOS and webkit2gtk on Linux. That difference decides which transparent video format you can fall back to.

How do you create a transparent always-on-top window in Electron?

In Electron, set transparent: true in the BrowserWindow constructor. The Electron docs describe this option as producing a fully transparent window. Add frame: false to remove the title bar and alwaysOnTop: true to keep the mascot above other windows.

const { app, BrowserWindow } = require('electron');
const path = require('path');

function createMascotWindow() {
  const win = new BrowserWindow({
    width: 220,
    height: 220,
    transparent: true,
    frame: false,
    alwaysOnTop: true,
    resizable: false,
    skipTaskbar: true,
    webPreferences: {
      preload: path.join(__dirname, 'preload.js'),
      contextIsolation: true,
      nodeIntegration: false
    }
  });
  win.loadFile('mascot.html');
  return win;
}

app.whenReady().then(createMascotWindow);

Keep contextIsolation on and nodeIntegration off. The renderer should reach the main process only through the functions a preload script exposes.

BrowserWindow also has setOpacity, which takes a number from 0.0 (fully transparent) to 1.0 (fully opaque). It fades the whole window, not just the character, so use it for a window-level fade and not to hide parts of the mascot.

The page loaded into the window holds a canvas sized to the mascot, with the Rive runtime script and your mascot code:

<canvas id="mascot" width="220" height="220"></canvas>

Check the page background as well. A body or container background colour will show as a box around the character even when the window itself is transparent.

How do you create a transparent window in Tauri?

In Tauri 2, windows are declared in the app.windows array of tauri.conf.json. The transparent option is a boolean on the window entry, and the configuration reference lists it as part of WindowConfig. A mascot window needs a few more settings:

{
  "app": {
    "windows": [
      {
        "label": "mascot",
        "title": "Assistant",
        "width": 220,
        "height": 220,
        "transparent": true,
        "decorations": false,
        "alwaysOnTop": true,
        "resizable": false,
        "skipTaskbar": true
      }
    ]
  }
}

Three notes from the Tauri sources:

  • Windows flash. The config reference lists noRedirectionBitmap on Windows, which can help avoid a white flash when a transparent window opens. Test the first frame on a clean machine.
  • macOS. The Tauri 2.12.1 release notes say transparency and fullscreen no longer need the macOS private API flag. Pin 2.12.1 or later if you want that behaviour.
  • Windows 7. Transparent windows are not a safe target on Windows 7, where they can cause visual artifacts or rendering failure.

If your mascot window is a React page, the same canvas code runs inside it. The steps for that setup are in how to use Rive in React and Next.js. If you are scaffolding the app with an AI builder first, adding a Rive mascot in Bolt.new, v0 and Replit covers that starting point.

How do you map AI assistant states to Rive mood numbers?

A floating assistant needs only a few poses. The simplest approach is one number input and a fixed table from state to number. The table below uses the mood numbers from Charmotion's character files, where each number selects one animation:

Assistant stateMood numberAnimation
Idle, waiting for input0idle
Happy, task finished1happy
Thinking, planning a reply3thinking
Sad, request failed4sad
Loading, tool call running5loading
Listening, microphone open6listening
Talking, reply streaming7talking
Attention, needs the user9attention

The renderer reads the state input once the file loads and writes the number whenever the assistant changes state. This is the same code in both shells:

var MOODS = { idle: 0, happy: 1, thinking: 3, sad: 4, loading: 5, listening: 6, talking: 7, attention: 9 };
var moodInput = null;

var player = new rive.Rive({
  src: 'mascot.riv',
  canvas: document.getElementById('mascot'),
  autoplay: true,
  stateMachines: 'CharacterStateMachine',
  onLoad: function () {
    player.resizeDrawingSurfaceToCanvas();
    var inputs = player.stateMachineInputs('CharacterStateMachine');
    moodInput = inputs.find(function (i) { return i.name === 'mood'; });
  }
});

function setState(state) {
  if (moodInput && MOODS[state] !== undefined) {
    moodInput.value = MOODS[state];
  }
}

The method names come from the Rive web runtime, which is loaded from its own package. Confirm them against the version you install, since the runtime API has changed across releases.

For richer data, Rive Data Binding exposes typed properties through a ViewModel that app code reads and writes at runtime. A state input is enough for a mascot that only changes pose. For a comparison of the two, see Rive data binding vs state machine inputs.

Exports from Rive's free plan play a Rive splash screen. A mascot you ship to users needs a paid plan to export the .riv file without it. Current plan details are at Rive pricing and commercial use.

How does AI assistant state reach the mascot window?

The answer depends on where your AI request runs.

In Electron, keep the API key and the model call in the main process, so the renderer never sees them. The main process then sends each state change to the mascot window. The preload script exposes one named function, not the whole IPC module. Electron's contextBridge page warns that passing the whole ipcRenderer module across the bridge gives an empty object on the receiving side, so expose a function:

const { contextBridge, ipcRenderer } = require('electron');

contextBridge.exposeInMainWorld('mascot', {
  onState: function (callback) {
    ipcRenderer.on('assistant:state', function (event, state) {
      callback(state);
    });
  }
});

In the main process, send each change to the window's web contents:

function sendState(win, state) {
  win.webContents.send('assistant:state', state);
}

The mascot code then calls window.mascot.onState(setState), which is the last line of the renderer script above. The Electron IPC tutorial describes this send and expose pattern in more detail.

In Tauri, the simplest design runs the AI request in the webview, since it is already JavaScript. The mascot and the chat UI then share one state variable, and the mascot script calls setState directly. If your request runs in the Rust side instead, you need Tauri's own event wiring to pass state to the mascot window. This guide does not cover that path, so check Tauri's documentation for its event API before you build it.

For a broader view of how a mascot maps to chat events, see animating an AI assistant's listening and talking states and how to add a mascot to onboarding and empty states, which use the same state-to-mood idea in other screens.

Which transparent video fallback and package size should you plan for?

A live Rive file is the best option when it works. Keep a video fallback for places where the runtime can't run, such as a sales page or a store preview. The fallback format depends on the engine:

EngineWhere it runsTransparent format to use
ChromiumElectron, WebView2 on WindowsWebM with VP9 alpha. Chromium-based browsers display its transparency.
WebKitWKWebView on macOS, webkit2gtk on LinuxHEVC with alpha in a .mov file. Apple documents this format for Safari.

Apple's documentation describes HEVC with alpha as a single video track that stores transparency with the picture. Other browsers generally do not render that alpha layer, so serve WebM and MOV side by side for the widest coverage.

Installer size differs by shell. Electron bundles Chromium and Node.js into the app, and its Distribution section covers packaging and signing. Neither Electron nor Tauri documents a typical installed size for an app like this, so build both and measure. On Windows, Tauri's WebView2 installation mode changes the installer by a known amount:

  • downloadBootstrapper adds 0 MB and needs internet access during install.
  • embedBootstrapper adds about 1.8 MB.
  • offlineInstaller adds about 127 MB.
  • fixedVersion adds about 180 MB.

Charmotion (our product) turns one finished, front-facing character image into a .riv with the CharacterStateMachine and mood input used above, along with transparent WebM and MOV exports for the fallback. It needs no separate rig. Plans and credits are on the pricing page. The code in this guide works with any Rive file that has a mood number input.

How to build an Electron or Tauri floating AI assistant mascot with Rive

  1. Export the .riv file. Export one .riv with a state machine that has a number input named mood. Ship it from a paid Rive plan so it has no splash screen.
  2. Create the transparent window. In Electron, set transparent true and frame false in BrowserWindow. In Tauri, set transparent true and decorations false on the window entry in tauri.conf.json.
  3. Size the window to the mascot. Keep the window about the size of the character, because transparent areas block clicks on what is behind them.
  4. Load the canvas and bind mood. Add a canvas, load the .riv with the Rive web runtime, and store the mood input after the file loads.
  5. Connect the assistant state. In Electron, send state from the main process over IPC through a preload function. In Tauri, call the same setState function from the webview code that runs the assistant.
  6. Add a transparent video fallback. Export transparent WebM for Chromium-based webviews and HEVC alpha MOV for WebKit, then test both on Windows and macOS.

Frequently asked questions

Can users click through the transparent part of the mascot window?

No. The Electron custom window styles guide states that transparent windows cannot be clicked through in the transparent area. Keep the window tight around the mascot so the blocked area stays small. If you need the mascot to stay out of the way, place it in a corner and let users dismiss it with a visible control.

Does a shipped mascot need a paid Rive plan?

Exports from Rive's free plan play a Rive splash screen, so a mascot you ship to users should come from a paid plan that exports .riv files without it. Rive's runtimes are open source and play any .riv file, so the paid part is the export, not the playback. See the Rive pricing and commercial use guide for current plan details as of December 2026.

Is Electron or Tauri the smaller choice for this app?

Neither project's documentation gives a typical installed size for a small mascot app, so the answer depends on your build. Electron ships Chromium and Node.js inside each app. Tauri uses the system webview, but on Windows its WebView2 installer mode can add anywhere from 0 MB to about 180 MB. Measure both builds before you choose.

Sources

Related guides