Avatar Generator
Deterministic avatars from any seed string. Gradient, blocks, and rings variants.
utils
Variants
gradient
blocks
rings
Installation
$ pnpm dlx shadcn@latest add @soultel/avatar-generatorNo namespace set up? npx shadcn@latest add https://asafefe.dev/r/avatar-generator.json works too.
Manual installation
- 1. Copy the source from the Code tab into components/avatar-generator.tsx.
Usage
import { AvatarGenerator } from "@/components/avatar-generator"
export function Example() {
return <AvatarGenerator seed="soultel" variant="gradient" />
}Props
| Prop | Type | Default | Description |
|---|---|---|---|
| seed | string | - | Any string. Same seed, same avatar. |
| variant | "gradient" | "blocks" | "rings" | "gradient" | Style. |
| size | number | 56 | Diameter in px. |
Notes
The same seed always produces the same avatar, so a user id or email gives every account a stable identity with no image hosting. Nothing is random at render time, which means it is safe for server rendering.
Props
| Prop | Type | Default |
|---|---|---|
seed | string | required |
variant | gradient blocks rings | gradient |
size | number | 56 |
How it works
A small hash turns the seed into a few hue values.
gradient maps them to a two stop linear gradient, blocks builds a mirrored identicon, and rings draws concentric circles. Swap the hash or the hue math if you want a different palette across your whole app.