Skip to content

PixelAvatar

Use PixelAvatar to give an agent, or anything else without a picture, a face of its own: generated from a seed, it stays the same everywhere without storing an image. For a person’s portrait from Raft’s avatar builder, use PersonAvatar; for an uploaded picture or initials, use Avatar.

PixelAvatar draws an 8×8 pixel-art avatar, the one Raft draws for an agent: generated from a seed string, or one of Raft’s 72 hand-drawn sprites. The same seed always gives the same picture, so an agent keeps its face everywhere without storing an image. A seed draws the same avatar here as Raft’s pixel:random:<seed>, and a sprite the same as Raft’s pixel:<name>.

The art is an inline SVG with crisp edges, so it stays sharp at any size and renders the same on the server. Its colors come from the generator’s own palette; only the frame follows the theme.

Demos

Basic

Each seed picks one of twelve color schemes and a left-right mirrored pattern.

Sprites

sprite picks one of Raft’s hand-drawn avatars instead of a seed. pixelAvatarSpriteSeries lists them in Raft’s picker sets of eight. A name this version doesn’t know draws Raft’s default, robot.

Size

small, medium and large match the control heights; a number is a side length in px.

Round

round makes a circle instead of the default softly rounded shape.

Bordered

The frame, a hairline ring, is on by default. bordered={false} drops it, for example when the avatar sits inside another frame.

Accessible name

Next to a visible name the avatar is decorative and hidden from assistive tech. On its own, give it alt: it becomes an image with that name.

Props

NameTypeDefaultDescriptionVersion
seedstring—Any string, usually a stable id. The same seed always draws the same avatar. Give seed or sprite.Unreleased
spritePixelAvatarSprite—One of Raft’s hand-drawn avatars, for example robot or cat.Unreleased
sizesmall | medium | large | numbermediumNamed control height, or a side length in px.Unreleased
roundbooleanfalseA circle instead of the theme’s shape.Unreleased
borderedbooleantrueThe theme’s frame around the art.Unreleased
altstringundefinedThe accessible name. Without it the avatar is decorative (aria-hidden).Unreleased

Other props go to the root <span>. size, round and bordered can be set for every PixelAvatar with ConfigProvider’s componentOptions.PixelAvatar.

From a Raft avatarUrl: pass the part after pixel:random: as seed, or the part after pixel: as sprite. The sprites are copied from Raft by pnpm --filter @pika-lab/scripts sync:raft-avatars <Raft checkout>.