Search results

Getting Started

The following section explains the steps required to create a simple avatar component using styles and its basic usage.

Setup Angular Environment

You can use Angular CLI to setup your Angular applications. To install Angular CLI use the following command.

npm install -g @angular/cli

Create an Angular Application

Start a new Angular application using below Angular CLI command.

ng new my-app
cd my-app

Adding Syncfusion Layouts package

  • All the available Essential JS 2 packages are published in registry.

  • Install layouts packages using below command.

npm install @syncfusion/ej2-layouts --save
The —save will instruct NPM to include the layouts package inside of the dependencies section of the package.json.

Adding CSS reference

The Avatar component CSS files are available in the ej2-layouts package folder. This can be referenced in your application using the following code.


@import '../node_modules/@syncfusion/ej2-base/styles/material.css';
@import '../node_modules/@syncfusion/ej2-layouts/styles/material.css';

We can also use CRG to generate combined component styles.

Add avatar into application

Modify the template in app.component.ts file to render avatar component.


import { Component } from '@angular/core';

    selector: 'my-app',
    template: `<div id='element'><span class="e-avatar">GR</span></div>`

export class AppComponent {}

Run the application

Run the application in the browser using the following command.

npm start

The following example shows a basic avatar component.

import { Component } from '@angular/core';

    selector: 'my-app',
    template: `
    <div id='element'>
            <span class="e-avatar e-avatar-xlarge"></span>
            <span class="e-avatar e-avatar-large"></span>
            <span class="e-avatar"></span>
            <span class="e-avatar e-avatar-small"></span>
            <span class="e-avatar e-avatar-xsmall"></span>

export class AppComponent { }
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';

 * Module
    imports: [
    declarations: [AppComponent],
    bootstrap: [AppComponent]
export class AppModule { }
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { AppModule } from './app.module';


See Also

Types of Avatar