Docs
Aster is a three-stroke agent mascot. One custom element, zero dependencies, MIT licensed. Every emote is driven by springs, so switching never cuts — each stroke glides from wherever it is to the next pose.
Install
npm install aster-mascot
Or straight from a CDN, no build step:
<script type="module" src="https://cdn.jsdelivr.net/npm/aster-mascot@0.3"></script>
Pin the version as above. While Aster is 0.x, a minor release can change behaviour, and an unpinned URL follows whatever is latest.
Size, gzipped (unminified source): /core 6.3 KB · element 9.0 KB · /favicon 8.6 KB · everything 11.2 KB.
Use
<aster-mascot emote="thinking" size="64"></aster-mascot>
<aster-mascot emote="happy" size="48" rounded="false" color="#e4572e"></aster-mascot>
import 'aster-mascot';
const aster = document.querySelector('aster-mascot');
aster.play('success');
aster.addEventListener('aster-emote', e => console.log(e.detail.emote));
Attributes
| Attribute | Default | Notes |
|---|---|---|
emote | idle | Any emote below. |
size | 64px | Number (px) or any CSS length. Or set --aster-size. |
color | currentColor | Any CSS color. Or set --aster-color. |
speed | 1 | Time multiplier. |
rounded | on | Round stroke ends. rounded="false" for flat ends, like the original art. |
paused | off | Freeze the animation. |
label | Aster | Accessible name. The emote is appended, e.g. “Aster, thinking”. |
announce | off | Announce emote changes to screen readers through a polite live region. |
Emotes
Click a tile to play it in the hero.
Methods and events
el.play(name)— switch emote. Does nothing if that emote is already playing, so it's safe to call on every agent event or token.el.play(name, { restart: true })— replay the current emote from the start.el.emote,el.speed,el.rounded,el.paused— read or set.aster-emoteevent — fires when the emote changes or restarts, withdetail.emote.
Agents
Map your agent's states to emotes with emoteFor(). Call it as often as you like: repeated calls with the same emote are ignored.
import { emoteFor } from 'aster-mascot';
agent.on('state', state => aster.play(emoteFor(state)));
| Agent state | Emote | When |
|---|---|---|
idle | idle | Nothing happening. |
greeting | wave | Session start, first message. |
listening | listening | User is typing or speaking. |
thinking | thinking | Model is reasoning, before output. |
tool | working | Running a tool call. |
working | working | Long task in progress. |
streaming | speaking | Writing a reply. |
waiting | listening | Blocked on the user: approval, question. |
approved / denied | yes / no | |
interrupted | surprised | |
done | success | Task finished. |
error | error | Task failed. |
cancelled | sad | |
offline | sleep | Disconnected, rate-limited, timed out. |
Emote names pass through unchanged, unknown states fall back to idle, and emoteFor(state, { ...AGENT_STATES, waiting: 'wave' }) overrides the map.
Accessibility
- The SVG has
role="img"and an accessible name that includes the emote, e.g. “Aster, thinking”. - Add
announceto speak changes through a polite live region. Changes are debounced (600 ms), so a burst of states is read once. Use it on the one mascot that shows agent state. prefers-reduced-motionstops looping motion; transitions stay gentle.
Behaviour
- Honours
prefers-reduced-motion: looping motion stops, transitions stay. - Pauses itself while off-screen.
- All instances share one
requestAnimationFrameloop. - Safe to import during server-side rendering.
Frameworks
It's a standard custom element, so it works as-is.
// React 19+
import { emoteFor } from 'aster-mascot';
<aster-mascot emote={emoteFor(agentState)} size="40" announce />
<!-- Vue: compilerOptions.isCustomElement = tag => tag === 'aster-mascot' -->
<aster-mascot :emote="state" size="40" />
Animated favicon
Put Aster in the browser tab. Handy for showing an agent's state while the user is in another tab — this page's own tab icon follows the hero.
import { animateFavicon } from 'aster-mascot/favicon';
const fav = animateFavicon({ emote: 'working' });
// later
fav.play('success'); // no-op if already playing
fav.set({ background: '#111', fps: 15 });
fav.stop(); // restores the page's original favicon
| Option | Default | Notes |
|---|---|---|
emote | idle | Starting emote. |
fps | 12 | Frames pushed to the tab, 1–30. |
size | 64 | Canvas size in px. |
color | auto | Follows light/dark mode, or contrasts with background. |
background | none | Fill behind Aster, e.g. #fff. Rounded square. |
radius | 0.22 | Background corner radius, fraction of size. |
padding | 0.02 | Inset around Aster, fraction of size. |
rounded | on | Round stroke ends. |
speed | 1 | Time multiplier. |
pauseWhenHidden | off | Stop drawing while the tab is hidden. |
Runs on a timer, not requestAnimationFrame, so it keeps going in background tabs. Browsers slow background timers to about once a second, so motion there is choppier by design. Identical frames are skipped, and it honours prefers-reduced-motion.
pauseWhenHidden is off by default because the favicon's job is to show agent state while the user is in another tab. That keeps a timer running there, which costs a little battery; turn it on if the icon only needs to animate while the page is visible.
Engine only
Render Aster anywhere — canvas, React Native, WebGL — with the DOM-free core.
import { createAster, VIEWBOX } from 'aster-mascot/core';
const aster = createAster({ emote: 'idle' }); // rounded by default
function frame(dt) {
aster.update(dt); // seconds
for (const { d, width } of aster.paths()) {
// draw path d, stroke width `width`, cap aster.linecap, in VIEWBOX space
}
}
License
MIT.