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 🙏

© 2025 – Pkg Stats / Ryan Hefner

ng-hub-ui-avatar

v19.0.0

Published

A powerful, flexible, and standalone Angular avatar component that generates and fetches user avatars from multiple sources including social media, Gravatar, or custom images with intelligent fallback system

Downloads

67

Readme

ng-hub-ui-avatar

npm version npm

Part of ng-hub-ui Family

This component is part of the ng-hub-ui ecosystem, which includes:

Credits and Attribution

This library is a fork of ngx-avatars, originally created by HaithemMosbahi and maintained by Tiago Casinhas.

The original work provided an excellent foundation for avatar management in Angular applications. This fork was created to:

  • Provide a standalone component architecture
  • Ensure compatibility with the latest Angular versions
  • Integrate seamlessly with the ng-hub-ui component ecosystem
  • Add new features and improvements while maintaining the original functionality

All credit for the original implementation goes to the original authors and contributors of ngx-avatars.

Description

A versatile avatar component for Angular applications that fetches or generates avatars based on user information. The component includes a sophisticated fallback system that attempts different sources if the primary source fails.

You can use this component with either a single source or multiple avatar sources, with the fallback system automatically selecting the first valid avatar.

Additionally, the component can display name initials or custom values as avatars.

Supported avatar sources:

  • Facebook
  • Google
  • Twitter
  • Instagram
  • Vkontakte (VK)
  • Skype
  • Gravatar (🚧 Under construction)
  • GitHub
  • Custom image
  • Name initials
  • Value

The fallback system follows the same order as the source list above, with Facebook having the highest priority.

Installation

Install the avatar component using npm:

npm install ng-hub-ui-avatar --save

Or using yarn:

yarn add ng-hub-ui-avatar

Usage

As this is a standalone component, you don't need to import any module. Just import the component directly in your standalone components or pages:

import { Component } from '@angular/core';
import { NgHubUiAvatar } from 'ng-hub-ui-avatar';

@Component({
  selector: 'app-my-component',
  standalone: true,
  imports: [NgHubUiAvatar],
  template: `
    <ng-hub-ui-avatar></ng-hub-ui-avatar>
  `
})
export class MyComponent { }

If you're using NgModule (legacy approach), you can import it in your components array:

import { NgModule } from '@angular/core';
import { NgHubUiAvatar } from 'ng-hub-ui-avatar';

@NgModule({
  imports: [
    // other imports...
  ],
  declarations: [AppComponent],
  bootstrap: [AppComponent]
})
export class AppModule { }

Use it in your components:

<ng-hub-ui-avatar></ng-hub-ui-avatar>

Examples

<ng-hub-ui-avatar facebookId="1508319875"></ng-hub-ui-avatar>
<ng-hub-ui-avatar googleId="1508319875"></ng-hub-ui-avatar>
<ng-hub-ui-avatar twitterId="1508319875"></ng-hub-ui-avatar>
<ng-hub-ui-avatar instagramId="dccomics" size="70"></ng-hub-ui-avatar>
<ng-hub-ui-avatar name="John Doe"></ng-hub-ui-avatar>
<ng-hub-ui-avatar value="75%"></ng-hub-ui-avatar>

<!-- Multiple sources with fallback -->
<ng-hub-ui-avatar 
  facebookId="userFacebookID" 
  skypeId="userSkypeID"
  googleId="google" 
  name="John Doe" 
  src="assets/avatar.jpg"
  value="28%" 
  size="100" 
  [round]="true">
</ng-hub-ui-avatar>

Options

| Attribute | Type | Default | Description | |------------------|------------|-----------|--------------------------------------------------------------------------------------------------------------------------------------| | facebookId | string | null | Facebook ID | | googleId | string | null | Google ID | | twitterId | string | null | Twitter Handle | | instagramId | string | null | Instagram Handle | | vkontakteId | string | null | VK ID | | skypeId | string | null | Skype ID | | githubId | string | null | Github ID | | src | string | null | Fallback image to use | | name | string | null | Will be used to generate avatar based on initials | | value | string | null | Show a value as avatar | | initialsSize | number | 0 | Limits the number of characters in initials (0 = no limit) | | bgColor | string | random | Background color (hex format, e.g., #FF0000) | | fgColor | string | #FFF | Text color (hex format, e.g., #FF0000) | | size | number | 50 | Size of the avatar | | textSizeRatio | number | 3 | Text size as a fraction of avatar size | | round | boolean | true | Round the avatar corners | | cornerRadius | number | 0 | Border radius for square avatars | | borderColor | string | undefined | Border color | | style | object | | Custom styles for root element | | clickOnAvatar | Output | | Event emitted on avatar click | | referrerpolicy | string | null | Referrer policy for image requests |

Support the Project

If you find this library helpful, consider supporting its development:

"Buy Me A Coffee"

Contributing

Contributions are welcome! Here's how you can help:

  1. Fork the repository
  2. Create your feature branch: git checkout -b feature/my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin feature/my-new-feature
  5. Submit a pull request

License

MIT © Carlos Morcillo