Example of Types in ASP.NET MVC Avatar Control
This sample demonstrates how different types of content, such as SVG icons, Font icons, words, letters, and images can be used with the avatar component.
Image
SVG
GR
Initial
FontIcon
User
Word
Custom
@Html.UiAvatar(new UiAvatarOptions { ImageUrl = Url.Content("~/Content/avatar/images/pic01.png"), Size = UiAvatarSize.XLarge, Shape = UiAvatarShape.Circle, Title = "Profile picture" })
@Html.UiAvatar(new UiAvatarOptions { IconCss = "svg_icons chrome", Size = UiAvatarSize.XLarge, Shape = UiAvatarShape.Circle, Title = "Chrome" })
@Html.UiAvatar(new UiAvatarOptions { Text = "GR", Size = UiAvatarSize.XLarge, Shape = UiAvatarShape.Circle })
@Html.UiAvatar(new UiAvatarOptions { IconCss = "e-people icons", Size = UiAvatarSize.XLarge, Shape = UiAvatarShape.Circle, Title = "People" })
@Html.UiAvatar(new UiAvatarOptions { Text = "User", Size = UiAvatarSize.XLarge, Shape = UiAvatarShape.Circle })
@Html.UiAvatar(new UiAvatarOptions { IconCss = "e-people icons", Size = UiAvatarSize.XLarge, Shape = UiAvatarShape.Circle, Color = "#8a2be2", CssClass = "custom", Title = "People" })
<style>
.sample_container { margin: 0 auto; }
.avatar-block { display: inline-block; vertical-align: top; }
.avatar-showcase { display: block; box-sizing: border-box; padding: 5px; margin: 5px; border: 1px solid var(--ui-border); border-radius: 8px; background: var(--ui-surface); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24); }
.avatar-showcase .card-content { display: flex; align-items: center; justify-content: space-evenly; gap: 6px; padding: 10px 0; text-align: center; }
.avatar-showcase .card-content .ui-avatar { font-size: 18px; }
.avatar-sub-block { display: inline-block; position: relative; margin: 7px; }
.svg_icons { display: inline-block; width: 32px; height: 32px; }
.chrome { background-color: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M16.033 11.049a5.155 5.155 0 1 1 0 10.312 5.156 5.156 0 0 1 0-10.312zM16.124 0c1.281-.003 9.659.318 14.268 9.043h-.016l.01.018c.33.578 3.745 6.94-.485 14.969 0 0-4.215 8.107-14.565 7.968l-.452-.012-.004.007-.004.007.02-.037c.564-.98 5.112-8.884 6.357-11.067l.016-.028.007-.008.04-.069.11-.127a7.085 7.085 0 0 0 1.457-2.967l.01-.046.035-.151c.088-.424.148-.944.128-1.549l-.006-.117v-.004l-.007-.143-.006-.07-.005-.079-.012-.116v-.01l-.001-.008-.016-.158a7.2 7.2 0 0 0-.096-.572l-.018-.081-.013-.064a9.801 9.801 0 0 0-.692-2.016c-.165-.243-.332-.489-.512-.733l-.142-.187 8.728-2.554s-10.538-.01-13.018-.001l.021.005H16.642l-.14-.013a7.034 7.034 0 0 0-1.132-.003l-.167.016h-.047l-.034-.001c-.193.002-1.213.045-2.492.764l-.005.003-.033.016a7.158 7.158 0 0 0-3.25 3.533l-.059.148-6.485-6.404s4.74 8.311 6.165 10.779l.065.113.023.088a7.14 7.14 0 0 0 7.777 5.118l.144-.02L14.854 32h-.027c-.667-.005-7.894-.234-12.744-7.906 0 0-4.925-7.698.37-16.573l.252-.411.001-.002C2.822 6.904 6.58.374 15.958.003c0 0 .057-.003.166-.003z'/%3E%3C/svg%3E") no-repeat center / contain; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M16.033 11.049a5.155 5.155 0 1 1 0 10.312 5.156 5.156 0 0 1 0-10.312zM16.124 0c1.281-.003 9.659.318 14.268 9.043h-.016l.01.018c.33.578 3.745 6.94-.485 14.969 0 0-4.215 8.107-14.565 7.968l-.452-.012-.004.007-.004.007.02-.037c.564-.98 5.112-8.884 6.357-11.067l.016-.028.007-.008.04-.069.11-.127a7.085 7.085 0 0 0 1.457-2.967l.01-.046.035-.151c.088-.424.148-.944.128-1.549l-.006-.117v-.004l-.007-.143-.006-.07-.005-.079-.012-.116v-.01l-.001-.008-.016-.158a7.2 7.2 0 0 0-.096-.572l-.018-.081-.013-.064a9.801 9.801 0 0 0-.692-2.016c-.165-.243-.332-.489-.512-.733l-.142-.187 8.728-2.554s-10.538-.01-13.018-.001l.021.005H16.642l-.14-.013a7.034 7.034 0 0 0-1.132-.003l-.167.016h-.047l-.034-.001c-.193.002-1.213.045-2.492.764l-.005.003-.033.016a7.158 7.158 0 0 0-3.25 3.533l-.059.148-6.485-6.404s4.74 8.311 6.165 10.779l.065.113.023.088a7.14 7.14 0 0 0 7.777 5.118l.144-.02L14.854 32h-.027c-.667-.005-7.894-.234-12.744-7.906 0 0-4.925-7.698.37-16.573l.252-.411.001-.002C2.822 6.904 6.58.374 15.958.003c0 0 .057-.003.166-.003z'/%3E%3C/svg%3E") no-repeat center / contain; }
.e-people.icons { display: inline-block; width: 1.2em; height: 1.2em; background-color: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M16 11c1.66 0 2.99-1.34 2.99-3S17.66 5 16 5s-3 1.34-3 3 1.34 3 3 3zm-8 0c1.66 0 2.99-1.34 2.99-3S9.66 5 8 5 5 6.34 5 8s1.34 3 3 3zm0 2c-2.33 0-7 1.17-7 3.5V19h14v-2.5c0-2.33-4.67-3.5-7-3.5zm8 0c-.29 0-.62.02-.97.05 1.16.84 1.97 1.97 1.97 3.45V19h6v-2.5c0-2.33-4.67-3.5-7-3.5z'/%3E%3C/svg%3E") no-repeat center / contain; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M16 11c1.66 0 2.99-1.34 2.99-3S17.66 5 16 5s-3 1.34-3 3 1.34 3 3 3zm-8 0c1.66 0 2.99-1.34 2.99-3S9.66 5 8 5 5 6.34 5 8s1.34 3 3 3zm0 2c-2.33 0-7 1.17-7 3.5V19h14v-2.5c0-2.33-4.67-3.5-7-3.5zm8 0c-.29 0-.62.02-.97.05 1.16.84 1.97 1.97 1.97 3.45V19h6v-2.5c0-2.33-4.67-3.5-7-3.5z'/%3E%3C/svg%3E") no-repeat center / contain; }
.ui-avatar.custom { color: #fff; }
</style>
<div class="control-section">
<div class="sample_container avatar-types" style="max-width: 500px">
<div class="avatar-block">
<div class="avatar-showcase" style="width: 150px">
<div class="card-content">
@Html.UiAvatar(new UiAvatarOptions { ImageUrl = Url.Content("~/Content/avatar/images/pic01.png"), Size = UiAvatarSize.XLarge, Shape = UiAvatarShape.Circle, Title = "Profile picture" })
</div>
<div class="card-content"><div>Image</div></div>
</div>
</div>
<div class="avatar-block">
<div class="avatar-showcase" style="width: 150px">
<div class="card-content">
@Html.UiAvatar(new UiAvatarOptions { IconCss = "svg_icons chrome", Size = UiAvatarSize.XLarge, Shape = UiAvatarShape.Circle, Title = "Chrome" })
</div>
<div class="card-content"><div>SVG</div></div>
</div>
</div>
<div class="avatar-block">
<div class="avatar-showcase" style="width: 150px">
<div class="card-content">
@Html.UiAvatar(new UiAvatarOptions { Text = "GR", Size = UiAvatarSize.XLarge, Shape = UiAvatarShape.Circle })
</div>
<div class="card-content"><div>Initial</div></div>
</div>
</div>
<div class="avatar-block">
<div class="avatar-showcase" style="width: 150px">
<div class="card-content">
@Html.UiAvatar(new UiAvatarOptions { IconCss = "e-people icons", Size = UiAvatarSize.XLarge, Shape = UiAvatarShape.Circle, Title = "People" })
</div>
<div class="card-content"><div>FontIcon</div></div>
</div>
</div>
<div class="avatar-block">
<div class="avatar-showcase" style="width: 150px">
<div class="card-content">
@Html.UiAvatar(new UiAvatarOptions { Text = "User", Size = UiAvatarSize.XLarge, Shape = UiAvatarShape.Circle })
</div>
<div class="card-content"><div>Word</div></div>
</div>
</div>
<div class="avatar-block">
<div class="avatar-showcase" style="width: 150px">
<div class="card-content">
@Html.UiAvatar(new UiAvatarOptions { IconCss = "e-people icons", Size = UiAvatarSize.XLarge, Shape = UiAvatarShape.Circle, Color = "#8a2be2", CssClass = "custom", Title = "People" })
</div>
<div class="card-content"><div>Custom</div></div>
</div>
</div>
</div>
</div>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using Lumen.UI.Mvc;
namespace YourApp.Controllers
{
public class AvatarController : Controller
{
// The page is Views/Avatar/Types.cshtml; it draws what ViewData holds.
public ActionResult Types()
{
return View();
}
}
}
@* Install once: Install-Package Lumen.UI.Mvc (or: dotnet add package Lumen.UI.Mvc) *@
@* Views/Web.config: <add namespace="Lumen.UI.Mvc" /> *@
@* Views/Shared/_Layout.cshtml *@
<head>
@Html.UiStyles()
<link rel="stylesheet" href="~/Content/site.css" />
</head>
<body>
@RenderBody()
@Html.UiScripts()
@RenderSection("scripts", required: false)
</body>
The Avatar component is flexible to support various types of icons and image. In this sample, the content like SVG, font icons, letters will be wrapped by the avatar element.