Initials

Usage#

HTTP-API (recommended)#

Our free HTTP-API is the easiest way to use this avatar style. Just use the following URL as image source.

https://avatars.dicebear.com/api/initials/:seed.svg

See the HTTP API documentation for more information.

Examples#

previewurl
https://avatars.dicebear.com/api/initials/John%20Doe.svg
https://avatars.dicebear.com/api/initials/John%20Doe.svg?fontSize=80
https://avatars.dicebear.com/api/initials/John%20Doe.svg?backgroundColorLevel=900

NPM#

Install the Avatars and this avatar style with the following command.

npm install --save @dicebear/avatars @dicebear/avatars-initials-sprites

Now you are ready to create your first Avatar.

import Avatars from '@dicebear/avatars';
import sprites from '@dicebear/avatars-initials-sprites';
let options = {};
let avatars = new Avatars(sprites, options);
let svg = avatars.create('custom-seed');

Options#

namealiastypedefaultdescription
radiusrnumber0Avatar border radius
dataUriboolfalseReturn avatar as data uri instead of XML
Not supported by the HTTP API
widthwnumbernullFixed width
heighthnumbernullFixed height
marginmnumber0Avatar margin in percent
HTTP-API limitation Max value 25
backgroundbstringnullAny valid color identifier
HTTP-API limitation Only hex (3-digit, 6-digit and 8-digit) values are allowed. Use url encoded hash: %23.
backgroundColorsarray of stringsnullPossible values: amber, blue, blueGrey, brown, cyan, deepOrange, deepPurple, green, grey, indigo, lightBlue, lightGreen, lime, orange, pink, purple, red, teal, yellow
backgroundColorLevelnumber600Possible values: 50, 100, 200, 300, 400, 500, 600, 700, 800, 900
fontSizenumber50Number between 1 and 100
charsnumber2Number between 0 and 2
boldboolfalse