@bihibar/blip
Blip is an animated SVG mascot for React. It ships three body shapes,
twenty-two states, and a small engine that acts each state out from a
storyboard of key poses and morphs every drawn feature (body, eyes, mouth)
between them. One requestAnimationFrame loop per mascot writes attributes
straight to the DOM; React renders once. The package has no runtime
dependencies besides React.
Install
npm install @bihibar/blip
# or
bun add @bihibar/blip
React 18.2 or newer is required (peer dependency). The package is ESM only and
ships its own type declarations.
Render
import { Blip } from '@bihibar/blip';
export function WelcomeBlip() {
return <Blip state="happy" shape="fin" size={240} />;
}
Blip renders a square wrapper <div> containing an
<svg viewBox="0 0 400 400" role="img">. Change state or shape at any time;
the mascot starts from whatever is currently on screen, so rapid changes never
jump.
Props
| Prop |
Type |
Default |
Meaning |
state |
BlipState |
'neutral' |
State to show. |
shape |
BlipShape |
config.shape |
Body silhouette. Overrides config.shape. |
config |
DeepPartial<BlipConfig> |
{} |
Overrides merged onto DEFAULT_BLIP_CONFIG. |
size |
number \| string |
280 |
Width and height. Numbers are pixels; strings are any CSS length. |
className |
string |
|
Applied to the wrapper <div>. |
style |
React.CSSProperties |
|
Applied to the wrapper <div>. |
frozenAt |
number |
|
Render one frame at this scene time (seconds) and run no animation loop. |
seed |
number |
hash of useId() |
Seeds the blink, glance and fidget schedules so several mascots on a page do not move in unison. |
onFrame |
(t: number) => void |
|
Called once per frame with the scene clock in seconds. |
aria-label |
string |
"Blip <phrase>" |
Accessible name of the SVG. The default follows the state: "Blip feeling happy", "Blip loading". |
interactive |
boolean |
false |
Clicks and taps poke the mascot: it squashes, hops and its eyes squeeze shut like a giggle. Pokes add up. |
entrance |
boolean |
false |
Drop in from above on mount and land with a squash. |
speed |
number |
1 |
How fast time runs: 1 is real time, 0.25 is quarter-speed slow motion. |
Shapes
| id |
Label |
Color |
bunny |
Bunny 🐰 |
#1000FF |
hash |
Hash #️⃣ |
#9E97FB |
fin |
Fin 🌿 |
#7DF799 |
bunny is the default. Every shape is normalized into the same 400 × 400 frame
and carries its own face anchors (eye centers, eye size and tilt, mouth position
and width). Switching shapes morphs the silhouette and the face over
transition.shapeDuration.
<Blip shape="hash" />
<Blip config={{ shape: 'fin' }} />
BLIP_SHAPES is the ordered list of ids; SHAPES[id] / getShape(id) return
the ShapeDef (label, emoji, color, outline, face anchors, bounds).
States
There are twenty-two states. Each has a kind:
- mood: a feeling, worn on the face.
- task: something Blip is doing, face still on.
- form: the body itself becomes the sign and the face steps aside.
The face is two eyes. Open eyes are capsules, and moods lower an eyelid across
them; closed eyes are smiles, chevrons, hearts or crosses. The body acts the
state out: each state has an entry (anticipation, action, settle) and most
then hold a loop for as long as the state lasts.
| State |
Emoji |
Kind |
Face |
Body |
neutral |
😐 |
mood |
open capsule eyes |
At rest. Arrives with a small exhale, then breathes, glances and fidgets. |
happy |
😊 |
mood |
closed in a smile (◠ ◠), cheeks pink |
A little hop of delight, then a contented rock from side to side. |
excited |
😄 |
mood |
wide open and bright, cheeks pink |
Jumps for it, then keeps bouncing on the spot. |
joy |
😆 |
mood |
squeezed shut, > <, cheeks pink |
Bursts out laughing: a hop, then three chuckles and a breath, leaning back. |
sad |
😢 |
mood |
lids drooping toward the outside, eyes a touch lower |
The eyes drop first, the body sinks after them and the ears come down last. Then slow sighs. |
crying |
😭 |
mood |
squeezed shut and sagging (∪), tears |
Crumples, then sobs: two hitches and a shaky breath. |
angry |
😠 |
mood |
lids dropping toward the nose |
Rears up and stomps, shudders, then glares and huffs. |
sleepy |
😴 |
mood |
lids half down, level |
Droops, slowly nods off, jolts awake, and starts nodding off again. |
wink |
😉 |
mood |
one eye open, one closed in a smile, cheeks pink |
Leans in, winks with a little lift, holds it for a beat. The eye then reopens. |
surprised |
😮 |
mood |
wide open |
No wind-up: it starts, hangs there wide-eyed, then blinks twice. |
thinking |
🤔 |
mood |
open, looking up and to the side |
The eyes go up and to the side first; the head tips after them. Now and then it weighs the other side. |
love |
😍 |
mood |
hearts, full blush |
Melts, the hearts pop open, then it swoons while they beat. |
confused |
😕 |
mood |
one eye wide, the other narrowed under a lid |
A small "huh?", the head tips one way, blinks, and tips the other. |
celebrate |
🥳 |
mood |
the biggest smile, cheeks pink |
Crouches, leaps, lands, then dances: hop to one side, hop to the other. |
shy |
☺️ |
mood |
small smiles, full blush |
Caught looking, turns away and shrinks a little; later it peeks back. |
dizzy |
😵 |
mood |
× × |
A bonk, then the whole body circles slowly, ears trailing behind. |
searching |
🔎 |
task |
a little narrowed, looking hard |
Perks up and scans: holds on one side, darts across, holds on the other. |
working |
🛠️ |
task |
lids lowered, looking down at the task |
Head down on the task, tapping away; pauses to check, blinks, and goes back to it. |
loading |
💬 |
form |
hidden |
Gathers itself and becomes three dots; a wave runs through them. |
processing |
⏳ |
form |
hidden |
Gathers into a dot with a ring turning round it. |
alert |
❗ |
form |
hidden |
Springs up into an exclamation mark, then hops twice for attention, again and again. |
success |
✅ |
form |
hidden |
Gathers and pops into a tick, with one small burst. |
BLIP_STATES is the ordered list of ids (the order of the table).
EXPRESSION_META[state] gives { label, emoji, kind, phrase } for building
state pickers; phrase completes "Blip …" in the accessible label.
Form states
loading, processing, alert and success are form states. The silhouette
melts into the sign over half a second, the same way one shape morphs into
another, and the face fades out as it goes. When the state ends the body melts
back into its own shape and the face returns.
loading: the body becomes the middle dot and two more slide out beside
it. A wave runs through the three, left to right.
processing: the body becomes a dot, and a ring that fades along its tail
turns round it.
alert: the body becomes the bar of an exclamation mark and the point drops
out of its foot.
success: the body becomes a tick. Six small dots burst outward once as it
lands, then nothing: the tick is the point.
The parts beside the body (the outer dots, the ring, the point, the burst) are
drawn in the body's color. They belong to the form and are always drawn;
motion.extras does not switch them off. Use thinking, searching or
working when the face should stay on while waiting.
The storyboard
Every state is authored as key poses, called beats, in
src/mascot/engine/storyboard.ts. A pose is a set of channels: how high the
body is, how squashed, how tilted, the head's turn, where the ears and legs
are, how far the lids are closed, and where the eyes look. A key names only the
channels it changes and how the motion arrives there (gently, fast, with a
little overshoot, or passing through without stopping). The engine only moves
between keys.
Most boards have an entry and a loop: happy hops once, then rocks from side
to side until the state changes. A few play once and hold (neutral, wink,
surprised, success). The storyboard is not part of the package API; the
Lab's Storyboard view draws it for the selected state.
How states change
- The body starts from the pose on screen. A new state blends from the
current pose to its first key and carries the momentum the body had, so
nothing pops. If the pose is too far away to cover in time (mid-leap, say),
the difference dies away on its own while the new state plays.
- Open eyes blend into each other. A change of eye family (open, smile,
chevron, heart, cross) closes the eye, swaps the outline while it is shut,
and opens the new one, so no in-between shape is ever shown.
- Colors and the rest of the face ease over
transition.duration on a
critically damped spring curve (no first-frame jump, no overshoot by
default). Entry gestures scale with the same duration.
- A mascot that mounts in a state starts in that state's loop or held
pose. The entry gesture plays only when
state changes.
At rest
While its face is on, Blip breathes and blinks, and it drifts by a fraction of
a unit; each state sets its own breathing rate and depth. When nothing is
being followed and the state does not direct the eyes itself, they glance
around. In neutral it also fidgets every few seconds: an ear flick, a hop, a
stretch, a curious tilt or a shimmy, on a schedule seeded by seed.
The rig
The parts follow each other by fixed rules, so they never disagree:
- The eyes move first and furthest. The head turns after them, on a softer
spring, and only for a real glance; small glances leave it still. Large
glances come with a blink.
- The head turns in fake 3D: the face slides across the body and foreshortens,
and the eye on the far side narrows. The slide is limited so the eyes never
leave the silhouette.
- The body leans and slides a little with the head.
- Ears and legs trail the body: they droop as it rises, swing against a
sideways move, shorten in a squash, and the knees bend with it.
Each shape has its own parts: the bunny's ears, the #'s legs, the fin's hood
and skirt lobes. Only those parts bend; the rest of the silhouette stays the
shape you drew.
States are carried by the mascot itself, not by icons beside it. The only
marks are tears and the parts of a form.
Configure
config is a deep partial: pass only the keys you want to change. Objects are
merged recursively, arrays are replaced, undefined is ignored.
<Blip
state="excited"
config={{
shape: 'hash',
body: { tintByState: true },
face: { eyeSize: 1.15, blush: 0.8 },
motion: { eyesFollowCursor: false },
}}
/>
Config reference
Top level:
| Key |
Type |
Default |
Meaning |
shape |
BlipShape |
'bunny' |
Body silhouette. The shape prop overrides it. |
statePalettes |
Partial<Record<BlipState, BlipStatePalette>> |
undefined |
Absolute color overrides per state ({ body?, face?, blush? }). Wins over body.tintByState. |
body:
| Key |
Type |
Default |
Meaning |
body.color |
hex \| 'auto' |
'auto' |
Body fill. 'auto' uses the shape's own color. |
body.tintByState |
boolean |
false |
Mix the body color toward a per-state tint (angry → red, sad → blue, …). |
body.shade |
number |
0.18 |
0–1. Strength of the soft radial shading toward the silhouette edge. |
body.shadeColor |
hex \| 'auto' |
'auto' |
Edge color of the shading. 'auto' derives a darker version of the body. |
body.squash |
number |
0.6 |
0–1. Squash-and-stretch amount applied to bounces and landings. 0.6 is as authored. |
face: