Generate SVG avatars with user initials in pure JS.
Generate avatars using a flexible API:
const UIAvatarSvg = require('ui-avatar-svg');
const svg = (new UIAvatarSvg())
.text('AB')
.size(64)
.bgColor('#ff0000')
.textColor('#ffffff')
.generate();
The generate()
function returns a string <svg...>
that can be embedded in your app.
text(string)
- User initials (defaultAB
)round(boolean)
- Is the avatar round instead of square (defaulttrue
)size(integer)
- Avatar size in px (default64
)bgColor(string)
- Background color (default#ff0000
)textColor(string)
- Text color (default#ffffff
)fontSize(float)
- Font size on a scale from0.1
-1.0
(default0.4
)fontWeight(string|integer)
- Font weight (defaultnormal
)fontFamily(string)
- Font family (default-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', Sans', 'Droid Sans', 'Helvetica Neue', sans-serif
)
UI Avatar SVG was created by Gilbert Pellegrom from Dev7studios. Released under the MIT license.