Syncfusion AI Assistant

How can I help you?

Getting Started with Blazor Avatar Component in Blazor Web App

27 Apr 20264 minutes to read

This section briefly explains about how to include Syncfusion® Blazor Avatar component in your Blazor Web App using Visual Studio, Visual Studio Code, and the .NET CLI.

Prerequisites

Create a new Blazor Web App in Visual Studio

Create a Blazor Web App using Visual Studio via Microsoft Templates or the Syncfusion® Blazor Extension. For detailed instructions, refer to the Blazor Web App Getting Started documentation.

Prerequisites

Create a new Blazor Web App in Visual Studio Code

Create a Blazor Web App using Visual Studio Code via Microsoft Templates or the Syncfusion® Blazor Extension. For detailed instructions, refer to the Blazor Web App Getting Started documentation.

For example, in a Blazor Web App with the Auto interactive render mode, use the following command in the integrated terminal (Ctrl+`):

dotnet new blazor -o BlazorWebApp -int Auto
cd BlazorWebApp
cd BlazorWebApp.Client

Prerequisites

Install the latest version of .NET SDK. If you previously installed the SDK, you can determine the installed version by executing the following command in a command prompt (Windows) or terminal (macOS) or command shell (Linux).

dotnet --version

Create a Blazor Web App using .NET CLI

Run the following command to create a new Blazor Web App in a command prompt (Windows) or terminal (macOS) or command shell (Linux). For detailed instructions, refer to the Blazor Web App Getting Started documentation.

For example, in a Blazor Web App with the Auto interactive render mode, use the following commands:

dotnet new blazor -o BlazorWebApp -int Auto
cd BlazorWebApp
cd BlazorWebApp.Client

This command creates a new Blazor Web App and places it in a new directory called BlazorWebApp inside your current location. See the Create a Blazor App and dotnet new CLI command topics for more details.

NOTE

Configure the appropriate Interactive render mode and Interactivity location while creating a Blazor Web App. For detailed information, refer to the interactive render mode documentation.

Install Syncfusion® Blazor packages

Install Syncfusion.Blazor.Themes NuGet package in your project using the NuGet Package Manager in Visual Studio (Tools → NuGet Package Manager → Manage NuGet Packages for Solution), or the integrated terminal in Visual Studio Code (dotnet add package), or the .NET CLI.

Alternatively, run the following commands in the Package Manager Console to achieve the same.

Install-Package Syncfusion.Blazor.Themes -Version 33.2.3

If using the WebAssembly or Auto render modes in the Blazor Web App, install this package in the client project.

NOTE

All Syncfusion Blazor packages are available on nuget.org. See the NuGet packages topic for details.

Add stylesheet

The theme stylesheet can be accessed from NuGet through Static Web Assets. Include the stylesheet reference in the ~/Components/App.razor file.

<link href="_content/Syncfusion.Blazor.Themes/fluent2.css" rel="stylesheet" />

NOTE

Check out the Blazor Themes topic to discover various methods (Static Web Assets, CDN, and CRG) for referencing themes in the Blazor application.

Add Syncfusion® Blazor Avatar component

Add the Syncfusion® Blazor Avatar component in the ~/Components/Pages/*.razor file.

<!-- xSmall Avatar-->
<div class="e-avatar e-avatar-xsmall image"></div>

<!-- Small Avatar-->
<div class="e-avatar e-avatar-small image"></div>

<!-- Avatar-->
<div class="e-avatar image"></div>

<!-- Large Avatar-->
<div class="e-avatar e-avatar-large image"></div>

<!-- xLarge Avatar-->
<div class="e-avatar e-avatar-xlarge image"></div>

<style>
    .e-avatar {
        background-image: url(https://ej2.syncfusion.com/demos/src/avatar/images/pic01.png);
    }
</style>
  • Press Ctrl+F5 (Windows) or +F5 (macOS) to launch the application. This will render the Syncfusion® Blazor Avatar component in the default web browser.
![Blazor Avatar Component

NOTE

View Sample in GitHub