dicebear-browser is a fork of dicebear that allows you to generate avatar images directly in the browser. The supported methods are toString and toDataUriSync. This makes it ideal for use in web applications that require quick and easy avatar generation. https://www.npmjs.com/package/dicebear-browser
npm install dicebear-browser
To generate an avatar, create a new avatar object using createAvatar
as described here (https://dicebear.com/how-to-use/js-library),
then convert the object with toString
or toDataUriSync
.
import { createAvatar } from "dicebear-browser/core";
import { botttsNeutral } from "dicebear-browser/collection/lib/index";
const avatar = createAvatar(avatars.botttsNeutral, {
seed: "Angel",
backgroundColor: ["1e88e5", "fdd835"],
backgroundType: ["gradientLinear"],
backgroundRotation: [-270],
mouth: ["smile02"],
});
document.querySelector("img").src = avatar.toDataUriSync();
DiceBear Browser is licensed under the MIT License.