Sprite
A pixel character built from swappable parts, that walks, sits and works.
Every sprite is five slots — skin, hair, eyes, outfit, accessory — drawn on one
fixed skeleton: the face box, the eye line, the shoulders and the hip. Because
the skeleton never moves, any combination of parts inherits the animations for
free.
Installation
pnpm dlx nachui add spriteInstalling by hand works the same as any other component: copy the file from
the Manual tab and adjust the import paths. The animations travel inside the
file as
SPRITE_CSS, so nothing else needs copying — either render with
withStyles or inject the string once:Anatomy
Seeds
Any string builds a sprite, and the same string always builds the same one — so
a username or an email works as an avatar with nothing stored.
nachui
figueroaignacio
mate
bit
vera
lupe
States
idle breathes and blinks, walk runs the two-frame walk cycle, work opens a
laptop, and loop plays the whole thing: walk in, sit down, work, get up.idle
walk
work
loop
Parts
Pass
parts to override whatever the seed picked, slot by slot. Colour is a
separate axis from shape, so six hair shapes and five colours are thirty heads.Standalone
spriteToSvg returns the whole sprite as one SVG string, animations included, so
it works anywhere a page's stylesheet cannot reach — a server response, a saved
file, a README. On this site every sprite is also a URL:The same seed always answers with the same image, so the response is cached as
immutable.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
seed | string | nachui | Any string. The same string builds the same sprite. |
parts | Partial<SpriteParts> | — | Overrides the seed, slot by slot. |
state | bust | idle | walk | work | loop | idle | What it is doing. |
size | number | 48 | Width in pixels; height follows the grid. |
Accessibility
The sprite is decorative and carries no label of its own. When it stands for a
person, put the name next to it in text rather than inside the drawing.
Found something to improve?
Notice a bug, typo, or missing detail on this page? Help us make the documentation better by opening a GitHub issue.