14.0.4 • Published 1 year ago

ngx-letters-avatar-14 v14.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

This fork support for Angular 14

npm i ngx-letters-avatar-14

Angular letters-avatar Component Ngx-letters-avatar (Angular 2+)

Component will genrate an avatar of your name's initial letters npm.io

Features

  • Set width and height properties or only one of them.
  • Set the avatarName property wich is used to display the initials.
  • Set the src property to show ordinary image in case you don't want to show letters avatar.
  • You can set the fontFamily for the characters.
  • You can set circular which is a boolean value to true or false to create a circlular shaped image.
  • You can set borderRadius property to make rounded border for the shape.
  • You can set id property for the image.

Getting Started

Installing

npm i ngx-letters-avatar

Configuration

Ensure you import the module and the dependencies:

import { BrowserModule } from "@angular/platform-browser";
import { NgModule } from "@angular/core";
import { LettersAvatarModule } from "ngx-letters-avatar";

@NgModule({
  declarations: [],
  imports: [BrowserModule, LettersAvatarModule],
  exports: [],
  providers: []
})
export class AppModule {}

Basic Usage

<div *ngFor="let user of users">
  <p>{{ user.name }}</p>
  <ngx-letters-avatar 
    [avatarName]="user.name" 
    [width]="40" 
    [circular]="true"
    fontFamily="Open Sans"></ngx-letters-avatar>
</div>
@Component({
  selector: 'app',
  templateUrl: "./app.component.html",
  styleUrls: ["./app.component.css"],
});

export class App {
  users = [
    { name: "Girgis A.Jacoub", id: 1 },
    { name: "Your name", id: 2 },
    { name: "another name", id: 3 },
  ];
}

Api for letters-avatar Component

These are the list of Inputs[] that are supported by the component. Configure the settings to meet your requirement.

InputTypeDescriptionDefault Value
widthnumberWill be used as the width of the image. if provided, you don't need to provide the height property as the height will be the same. only set height and width in case you want to set differnt width and height values.60
heightnumberWill be used as the height of the image. if provided, you don't need to provide the width property.none
avatarNamestringThe name which the initial letters are taken from.none
srcstringThe src of the image. provide it in case you want to show image instead of letters avatar.none
classNamestringTo provide a class or classes for the image tag.none
fontFamilystringTo provide a font fanily for the characters.Arial
circularbooleanto make a circular shaped img.false
borderRadiusnumberto make a rounded bordered shape image.none
idstringto provide id attribute for the image tag.none