Socket
Book a DemoInstallSign in
Socket

emoji-avatar

Package Overview
Dependencies
Maintainers
0
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

emoji-avatar

Emoji Avatars generator for fun.

latest
Source
npmnpm
Version
1.0.2
Version published
Weekly downloads
2
Maintainers
0
Weekly downloads
 
Created
Source

avatar
Emoji Avatar
bundle size

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

Keywords

avatar

FAQs

Package last updated on 02 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts