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-native-user-avatar

v2.0.0

Published

React Native component for a user avatar with fallback to colored initials

Downloads

9,029

Readme

React Native User Avatar

npm version npm downloads CI TypeScript License: MIT

Coverage lines Coverage functions Coverage branches Coverage statements

A bare-bones user avatar component that falls back to the user's initials on a deterministic colored background. Works on iOS, Android, and Web, ships with TypeScript types, and has no runtime polyfills — it uses the global fetch/AbortController available in modern React Native.

Inspired by react-user-avatar and ported to React Native.

iOS Screenshot | Android Screenshot :-------------------------:|:-------------------------: |

Installation

npm install react-native-user-avatar
# or
yarn add react-native-user-avatar

react and react-native are peer dependencies — this library uses whatever version your app already has installed. No extra native setup is required; it is a pure JavaScript component.

Usage

The fallback avatar's color can be set with the bgColor prop, or customized by passing an array of bgColors. The same name always maps to the same color.

import UserAvatar from 'react-native-user-avatar';
import { View } from 'react-native';

export default function App() {
  return (
    <View>
      <UserAvatar size={100} name="Avishay Bar" />
      <UserAvatar
        size={100}
        name="Avishay Bar"
        src="https://dummyimage.com/100x100/000/fff"
      />
      <UserAvatar size={50} name="John Doe" bgColors={['#ccc', '#fafafa', '#ccaabb']} />
      <UserAvatar size={50} name="John Doe" />
      <UserAvatar size={50} name="Jane Doe" bgColor="#000" />
    </View>
  );
}

TypeScript

Types are bundled — no @types/* package is needed. You can import the prop type:

import UserAvatar, { UserAvatarProps } from 'react-native-user-avatar';

Props

| Attribute | Type | Default | Description | | ------------------- | -------------------------- | -------------- | ----------- | | name | string | 'John Doe' | Name used to generate the initials. | | src | string | undefined | Remote image URL. Shown when it resolves to a valid image. | | bgColor | string | undefined | Force a specific background color for the initials. | | bgColors | string[] | built-in palette | Palette the deterministic background color is picked from. | | textColor | string | '#fff' | Color of the initials text. | | size | number | 32 | Avatar width/height and initials font scale. | | imageStyle | StyleProp<ImageStyle> | undefined | Extra style applied to the image. | | textStyle | StyleProp<TextStyle> | undefined | Extra style applied to the initials text. | | style | StyleProp<ViewStyle> | undefined | Extra style applied to the outer container. | | borderRadius | number | size / 2 | Border radius of the avatar (defaults to a circle). | | component | ReactNode | undefined | Render a custom element instead of initials/image. | | noUpperCase | boolean | false | Keep initials in their original case. | | ignoreContentType | boolean | false | Skip the image/* content-type check on src (e.g. for S3 URLs without an extension). |

Web & Expo

The component works in Expo and react-native-web projects without extra configuration. See the Example/ app for a runnable Expo demo (iOS, Android, and Web).

Migrating from v1 to v2

v2 is a modernization release. It is a drop-in replacement for most apps, but note:

  • react/react-native are now peer dependencies. They are no longer bundled as hard dependencies, so your app's versions are always used.
  • Polyfills removed. abortcontroller-polyfill and node-fetch are gone; the component relies on the global fetch/AbortController (available in RN ≥ 0.60).
  • textStyle now works reliably, including after the initial render (#117).
  • Fewer console warnings — no defaultProps deprecation warning, and aborted image fetches no longer log.
  • TypeScript types are correct and bundled (#114, #129).
  • Initials are now capped at 3 characters.

Contributing

Contributions are welcome — see CONTRIBUTING.md. Working in this repo with an AI assistant? Start from CLAUDE.md.

Credits

@wbinnssmith for creating react-user-avatar.

License

MIT