npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-avatar-initials

v1.0.0

Published

Customizable, deterministic avatar generator and initials component for React with zero dependencies.

Readme

react-avatar-initials

A customizable, deterministic user avatar and initials generator for React with zero dependencies.

Installation

npm install react-avatar-initials

or with yarn:

yarn add react-avatar-initials

or with pnpm:

pnpm add react-avatar-initials

Quick Start

import React from 'react';
import Avatar from 'react-avatar-initials';

export default function App() {
  return (
    <div style={{ display: 'flex', gap: '12px' }}>
      {/* Generates deterministic pastel background from name */}
      <Avatar name="Sarah Connor" />

      {/* Modern gradient background */}
      <Avatar name="John Doe" colorMode="gradient" />

      {/* With custom size and status indicator */}
      <Avatar name="Alex Morgan" size={48} status="online" />

      {/* Image with automatic initials fallback on error */}
      <Avatar
        name="Bruce Wayne"
        src="https://example.com/avatar.jpg"
        size={48}
      />
    </div>
  );
}

Features & Usage

1. Shape Variants

// Circle (default)
<Avatar name="Jane Doe" variant="circle" />

// Square
<Avatar name="Jane Doe" variant="square" />

// Rounded corners
<Avatar name="Jane Doe" variant="rounded" borderRadius={10} />

2. Color Themes

// Pastel colors (default)
<Avatar name="Jane Doe" colorMode="pastel" />

// Vibrant CSS gradients
<Avatar name="Jane Doe" colorMode="gradient" />

// Monochrome slate/dark
<Avatar name="Jane Doe" colorMode="monochrome" />

// Custom solid color
<Avatar name="Jane Doe" backgroundColor="#3b82f6" textColor="#ffffff" />

3. Status Indicators

<Avatar name="Alice" status="online" />
<Avatar name="Bob" status="busy" />
<Avatar name="Charlie" status="away" />
<Avatar name="Diana" status="offline" />

4. AvatarGroup

Stack multiple avatars with an automatic remainder indicator.

import { AvatarGroup, Avatar } from 'react-avatar-initials';

<AvatarGroup max={3}>
  <Avatar name="Emma Watson" />
  <Avatar name="Daniel Radcliffe" />
  <Avatar name="Rupert Grint" />
  <Avatar name="Tom Felton" />
</AvatarGroup>

5. useAvatar Hook

Compute initials and colors programmatically without rendering the component:

import { useAvatar } from 'react-avatar-initials';

const { initials, background, text } = useAvatar('John Doe', {
  colorMode: 'gradient',
});

Props

| Prop | Type | Default | Description | | :--- | :--- | :--- | :--- | | name | string | undefined | User name used to extract initials & pick colors | | src | string | undefined | Image URL (falls back to initials on load failure) | | size | number \| string | 40 | Width and height in pixels | | variant | 'circle' \| 'square' \| 'rounded' | 'circle' | Shape style | | borderRadius | number \| string | 8 | Corner radius when variant="rounded" | | colorMode | 'pastel' \| 'gradient' \| 'monochrome' \| 'custom' | 'pastel' | Color selection strategy | | backgroundColor | string | undefined | Custom background color override | | textColor | string | undefined | Custom text color override | | status | 'online' \| 'offline' \| 'busy' \| 'away' \| string | undefined | Status dot badge | | maxInitials | number | 2 | Number of initial letters (1, 2, or 3) | | border | string | undefined | Border stroke (e.g. '2px solid white') | | fontSize | number \| string | Auto | Custom font size override |

License

MIT