pixel-avatar-motion
v0.1.1
Published
100 animated pixel-art avatars with eight states, built on @ga1az/react-pixel-motion.
Maintainers
Readme
pixel-avatar-motion
100 hand-built pixel-art avatars, each with eight animation states, rendered through
@ga1az/react-pixel-motion.
- 100 avatars with stable ids (
px-001…px-100), names, palettes and traits. - 8 states:
idle,walking,working,talking,thinking,asking,healing,sleeping. - Zero asset setup: every 240×320 sprite sheet is embedded as a PNG data URL.
- TypeScript, ESM and CommonJS builds, React 18 and 19.
Install
pnpm add pixel-avatar-motion
# or: npm install pixel-avatar-motionreact and react-dom are peer dependencies and are not bundled.
Usage
import { PixelAvatar } from "pixel-avatar-motion";
export function Assistant() {
return <PixelAvatar id="px-042" state="thinking" scale={5} />;
}Switch states as your app changes:
import { PixelAvatar, type AvatarState } from "pixel-avatar-motion";
function StatusAvatar({ state }: { state: AvatarState }) {
return (
<PixelAvatar
id="px-007"
state={state}
scale={4}
onFrameChange={(frame) => console.log("frame", frame)}
/>
);
}Browse every avatar and state in the bundled showcase app under apps/web.
API
<PixelAvatar /> accepts:
| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| id | AvatarId | required | Avatar id from px-001 to px-100. |
| state | AvatarState | "idle" | Animation row to play. |
| scale | number | 4 | Integer scale; the rendered size is 40 * scale square. |
| fps | number | per state | Overrides the state's default frame rate. |
| playing | boolean | true | Pause or resume the animation. |
| loop | boolean | true | Loop the six-frame cycle. |
| pixelated | boolean | true | Keep hard pixel edges when scaled. |
| className, style, title | — | — | Standard wrapper attributes. |
| onFrameChange | (frame: number) => void | — | Called on every frame change. |
| onAnimationEnd | () => void | — | Called when a non-looping cycle ends. |
The rendered wrapper is a <span role="img"> with an accessible label such as
"Ada Adeyemi — thinking" and data-avatar-id / data-avatar-state attributes.
Registry helpers
import {
AVATARS,
AVATAR_COUNT,
AVATAR_IDS,
AVATAR_STATES,
AVATAR_STATE_INFO,
SPRITES,
SPRITE_MANIFEST,
getAvatar,
getAvatarSprite,
isAvatarId,
} from "pixel-avatar-motion";| Export | Description |
| --- | --- |
| AVATARS | Full definitions: id, name, traits and palette. |
| AVATAR_COUNT | 100. |
| AVATAR_IDS | Tuple and AvatarId union of all ids. |
| AVATAR_STATES | State names in sprite-row order. |
| AVATAR_STATE_INFO | Human labels, descriptions and default frame rates. |
| SPRITES | Record<AvatarId, string> of PNG data URLs. |
| SPRITE_MANIFEST | Frame size, column count and row count. |
| getAvatar(id) | Definition or undefined. |
| getAvatarSprite(id) | Data URL or undefined. |
| isAvatarId(value) | Type guard for arbitrary strings. |
States
| State | Default fps | Frames | What happens |
| --- | --- | --- | --- |
| idle | 5 | 6 | Breathing and an occasional blink. |
| walking | 10 | 6 | In-place walk cycle with swinging arms and dust. |
| working | 6 | 6 | Typing at a desk with a spinning gear. |
| talking | 8 | 6 | Mouth movement, a gesturing hand and speech dots. |
| thinking | 5 | 6 | Hand on the chin with drifting thought bubbles. |
| asking | 6 | 6 | Raised hand and a bouncing question mark. |
| healing | 8 | 6 | Happy closed eyes and rising sparkles. |
| sleeping | 3 | 6 | Tilted head, closed eyes and floating Zs. |
Bundle size
The package ships one 240×320 PNG per avatar. All 100 sheets total roughly 576 KB of PNG data (about 768 KB once base64-encoded, inside the 811 KB JS bundle, before gzip). Importing the package includes every sheet because they share one registry. If you need a smaller payload, import a subset at build time or copy the individual data URLs you use.
Development
From the repository root:
pnpm install
pnpm generate # rebuild src/generated from scripts/art
pnpm test
pnpm typecheck
pnpm build
pnpm dev # showcase appThe art is generated procedurally from scripts/art/; no external image assets
are required. Edit the drawing code, run pnpm generate, and the sprite sheets,
avatar metadata and TypeScript declarations are regenerated together.
License
MIT
