# Getting Started with the Avatar

This tutorial explains how to set up a basic Telerik UI for ASP.NET Core Avatar and highlights the major steps in the configuration of the component.

You will initialize an Avatar component with different appearance-related options. Finally, you can run the sample code in [Telerik REPL](https://netcorerepl.telerik.com/) and continue exploring the components.

![Sample Telerik UI for ASP.NET Core Avatar](https://www.telerik.com/aspnet-core-ui/documentation/assets/6e40cbe50c17222096d8b59e215b806a/avatar-getting-started.png)

## Prerequisites

To successfully complete the tutorial, you need a project that is already configured to use the Telerik UI for ASP.NET Core components:

* To create a new pre-configured project for the Telerik UI for ASP.NET Core components, you can use [a project template](https://www.telerik.com/aspnet-core-ui/documentation/vs-integration/new-project-wizard).

## 1. Prepare the CSHTML File

The first step is to add the required directives at the top of the `.cshtml` document:

* To use the Telerik UI for ASP.NET Core HtmlHelpers:

  ```cshtml
  @using Kendo.Mvc.UI
  ```

* To use the Telerik UI for ASP.NET Core TagHelpers:

  ```cshtml
  @addTagHelper *, Kendo.Mvc
  ```

Optionally, you can structure the View content by adding the desired HTML elements like headings, divs, paragraphs, and others.

```Razor HtmlHelper
    @using Kendo.Mvc.UI

    <div id="avatar-container">

    </div>
```

```Razor TagHelper
    @addTagHelper *, Kendo.Mvc

    <div id="avatar-container">

    </div>
```

## 2. Initialize the Avatar

Use the Avatar HtmlHelper or TagHelper to add the component to a page:

* The `Name()` configuration method is mandatory as its value is used for the `id` and the `name` attributes of the Avatar element.
* The `Type()` option specifies the type of the Avatar.
* The `Text()` defines the text that will be displayed in the Avatar, when the `Type` option is set to `AvatarType.Text`.
* The `Image()` specifies the URL of the image that will be displayed in the Avatar, when the `Type` option is `AvatarType.Image`.
* The `Icon()` sets the name of the icon that will be displayed in the Avatar, when the `Type` is `AvatarType.Icon`.
* The `Rounded()` option defines the component shape.

```Razor HtmlHelper
    @using Kendo.Mvc.UI

    <div id="avatar-container">
        @(Html.Kendo().Avatar()
            .Name("avatar")
            .Type(AvatarType.Image)
            .Rounded(Rounded.Full)
            .Image("https://demos.telerik.com/aspnet-core/shared/web/Customers/FAMIA.jpg")
        )
    </div>
```

```Razor TagHelper
    @addTagHelper *, Kendo.Mvc

    <div id="avatar-container">
        <kendo-avatar name="avatar"
            type="AvatarType.Image"
            rounded="Rounded.Full"
            image="https://demos.telerik.com/aspnet-core/shared/web/Customers/FAMIA.jpg">
        </kendo-avatar>
    </div>
```

## 3. Customize the Appearance of the Avatar

The configuration options like `Size`, `FillMode`, `Border`, `Rounded`, and more allow you to control the appearance of the Avatar component.

```Razor HtmlHelper
    @using Kendo.Mvc.UI

    <div id="avatar-container">
        @(Html.Kendo().Avatar()
            .Name("avatar")
            .Type(AvatarType.Image)
            .Size(ComponentSize.Large)
            .FillMode(AvatarFillMode.Outline)
            .Rounded(Rounded.Large)
            .Border(true)
            .Image("https://demos.telerik.com/aspnet-core/shared/web/Customers/FAMIA.jpg")
        )
    </div>
```

```Razor TagHelper
    @addTagHelper *, Kendo.Mvc

    <div id="avatar-container">
        <kendo-avatar name="avatar"
            type="AvatarType.Image"
            size="ComponentSize.Large"
            fill-mode="AvatarFillMode.Outline"
            border="true"
            rounded="Rounded.Large"
            image="https://demos.telerik.com/aspnet-core/shared/web/Customers/FAMIA.jpg">
        </kendo-avatar>
    </div>
```

## 4. (Optional) Reference Existing Avatar Instances

You can reference the Avatar instances that you have created and build on top of their existing configuration. Use the `Name()` value of the component to get its reference.

```Razor HtmlHelper
    @(Html.Kendo().Avatar()
        .Name("avatar")
        .Type(AvatarType.Image)
        .Rounded(Rounded.Full)
        .Image("https://demos.telerik.com/aspnet-core/shared/web/Customers/FAMIA.jpg")
    )
```

```Razor TagHelper
    @addTagHelper *, Kendo.Mvc

    <kendo-avatar name="avatar"
        type="AvatarType.Image"
        rounded="Rounded.Full"
        image="https://demos.telerik.com/aspnet-core/shared/web/Customers/FAMIA.jpg">
    </kendo-avatar>
```

```JS script
    <script>
        $(document).ready(function() {
            var avatar = $("#avatar").data("kendoAvatar"); // The `avatar` variable holds a reference to the existing Avatar instance of the helper.
        });
    </script>
```

For more information on referencing specific helper instances, see the [Methods and Events](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/helper-basics/events-and-methods) article.

## Explore this Tutorial in REPL

You can continue experimenting with the code sample above by running it in the Telerik REPL server playground:

* [Sample code with the Avatar HtmlHelper](https://netcorerepl.telerik.com/cnvFcQvp48l9OYrm30)
* [Sample code with the Avatar TagHelper](https://netcorerepl.telerik.com/QHPPmmFf48CPQxnG55)

## Next Steps

* [Configuring the Avatar Appearance](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/layout/avatar/appearance)

## See Also

* [Integrating the Avatar for ASP.NET Core into a Grid (Demo)](https://demos.telerik.com/aspnet-core/avatar/gridintegration)

* [Client-Side API of the Avatar](https://docs.telerik.com/kendo-ui/api/ui/avatar)

* [Server-Side API of the Avatar HtmlHelper](https://www.telerik.com/aspnet-core-ui/documentation/api/avatar)

* [Server-Side API of the Avatar TagHelper](https://www.telerik.com/aspnet-core-ui/documentation/api/taghelpers/avatar)

* [Knowledge Base Section](https://www.telerik.com/aspnet-core-ui/documentation/knowledge-base)
