Skip to content

Avatar Groups

A group is one SVG, rendered through a single <img>, so it needs no stylesheet.

import { createAvatarGroup } from "@avatar-generator/core";
const group = createAvatarGroup(faces, ["ana", "ben", "chi", "dee", "eli"], {
size: 40,
max: 3,
title: "Ana, Ben and 3 others",
});
img.src = group.toDataUri();
img.alt = group.label;
img.width = group.width;
img.height = group.height;
OptionDefaultDescription
size48Diameter of each avatar in pixels
overlap0.25Fraction of each avatar covered by the next, up to 0.9
max-Show this many, then a +N badge
ringWidth2Width of the ring separating avatars
ringColor#ffffffRing colour. Match your page background
options-Options for every avatar. An item’s own options win
badgeColor#E5E7EBBackground of the badge
badgeTextColor#1F2933Text of the badge
title-Accessible name. Defaults to a count such as 5 avatars

Items are seeds, or full options when one person needs their own.

In your framework

// React
import { AvatarGroup } from "@avatar-generator/react";
<AvatarGroup style={faces} items={seeds} options={{ size: 40, max: 3 }} alt="Project team" />;
<!-- Vue -->
<script setup>
import { AvatarGroup } from "@avatar-generator/vue";
</script>
<template>
<AvatarGroup :style="faces" :items="seeds" :options="{ size: 40, max: 3 }" alt="Project team" />
</template>
<!-- Svelte -->
<script>
import AvatarGroup from "@avatar-generator/svelte/AvatarGroup.svelte";
</script>
<AvatarGroup style={faces} items={seeds} options={{ size: 40, max: 3 }} alt="Project team" />
<!-- Angular: add AvatarGroupComponent to your component's imports -->
<avatar-generator-group [style]="faces" [items]="seeds" [options]="{ size: 40, max: 3 }" alt="Project team" />
// Web component
const el = document.createElement("avatar-generator-group");
el.styleImpl = faces;
el.items = seeds;
el.options = { size: 40, max: 3 };
el.setAttribute("alt", "Project team");

Built by · MIT licensed