emoji-avatar
v1.0.2
Published
Emoji Avatars generator for fun.
Downloads
54
Maintainers
Readme
Generate an emoji avatar from a string. Demo
Getting Started
npm i emoji-avatar
import { createAvatar } from 'emoji-avatar';
const avatar = createAvatar("john doe")
console.log(avatar)
{
"color": "hsl(3, 73%, 83%)",
"url": "https://cdn.../1f368.svg"
}
React Example
function UserAvatar({ username }) {
const avatar = createAvatar(username);
return (
<div style={{ background: avatar.color }}>
<img src={avatar.url} alt={username} />
</div>
);
}
API
createAvatar(input: string): Avatar
colorHash(hash: number): string
emojiHash(hash: number, emojiRanges?: EmojiRangeName[]): string
See JSDoc comments in source for details.
Motivation
Inspired from Rainbow Wallet