AvatarPicker

Pick an avatar from a grid. One accent ring glides to your choice, the big preview swaps on a spring, arrow keys move across the grid and Shuffle rolls a random one. Inputs.

Open playground
Avatar 3

About

AvatarPicker is a React component in the Inputs category of smoui. It is typed, ships no stylesheet, follows your theme through CSS variables, and honors prefers-reduced-motion. Import it with import { AvatarPicker } from "@ashutoshswamy/smoui" and set label, options, value among its 4 props.

Install

Terminal
npm i @ashutoshswamy/smoui

Usage

TSX
import { AvatarPicker } from "@ashutoshswamy/smoui";

<AvatarPicker label="Profile picture" defaultValue="2" onChange={(id) => save(id)} />

Props 4

label

Accessible name for the group.

string
options

Choices. Give `src` for photos or `palette` (0-7) for a mesh.

{ id; name; src?; palette? }[]default 8 mesh avatars
value / defaultValue / onChange

Selected option id, controlled or not.

string / string / (id) => void
size / ringColor

Choice size, and the gap colour cut around the ring. Match the surface behind.

number / stringdefault 56 / "var(--smoui-ring, Canvas)"