JGuang

Shapes

Shapes · DiceBear

Preview
npm install @dicebear/core@9.4.2 @dicebear/collection@9.4.2

Shapes

Layered geometric shapes with offsets and rotation.

Install

npm install @dicebear/core@9.4.2 @dicebear/collection@9.4.2

Generate an avatar

The same seed always produces the same avatar, so a user ID or username works as a seed. Avatars are generated locally without a network service.

import { createAvatar } from '@dicebear/core';
import { shapes } from '@dicebear/collection';

// “Shapes” by DiceBear, CC0 1.0
const avatar = createAvatar(shapes, {
  seed: 'Aria Chen',
  size: 128,
  radius: 50,
});

export const svg = avatar.toString();     // inline SVG markup
export const dataUri = avatar.toDataUri(); // use as an <img> src

React component:

import { useMemo } from 'react';
import { createAvatar } from '@dicebear/core';
import { shapes } from '@dicebear/collection';

export function UserAvatar({ seed, size = 64 }: { seed: string; size?: number }) {
  const src = useMemo(() => createAvatar(shapes, { seed, size }).toDataUri(), [seed, size]);
  return <img src={src} width={size} height={size} alt={`Avatar for ${seed}`} />;
}

Options

Common options: seed, size, radius, backgroundColor, flip, rotate, scale.

Style options: shape1, shape1Color, shape1OffsetX, shape1OffsetY, shape1Rotation, shape2, shape2Color, shape2OffsetX, shape2OffsetY, shape2Rotation, shape3, shape3Color, shape3OffsetX, shape3OffsetY, shape3Rotation.

Full option reference: https://www.dicebear.com/styles/shapes/

License and attribution