Example of Default in ASP.NET MVC Badge Control
This sample demonstrates the default functionalities of the badge. To apply the badge, add .e-badge class to the element.
@Html.UiBadge(new UiBadgeOptions { Content = "14", Color = UiBadgeColor.Info, Position = UiBadgePosition.Notification })
@Html.UiBadge(new UiBadgeOptions { Content = "48", Color = UiBadgeColor.Success, Position = UiBadgePosition.Notification })
@Html.UiBadge(new UiBadgeOptions { Content = "99", Color = UiBadgeColor.Secondary, Position = UiBadgePosition.Notification })
<style>
.sample_container { max-width: 900px; margin: 0 auto; padding: 24px 0; }
.badge-block { display: inline-block; position: relative; margin: 14px 18px; vertical-align: middle; }
.badge-showcase { display: inline-block; width: 180px; margin: 10px; padding: 16px 8px; border: 1px solid var(--ui-border); border-radius: 8px; background: var(--ui-surface); text-align: center; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
.badge-showcase .text { margin-top: 12px; font-size: 12px; }
.badge-showcase button { position: relative; }
.margin { margin: 12px 0 4px; }
.fontSize { font-weight: 600; font-size: 15px; }
.svg_icons { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 8px; color: #fff; font-weight: 700; font-size: 16px; }
.whatsapp { background: #25d366; } .twitter { background: #1da1f2; } .facebook { background: #1877f2; } .skype { background: #00aff0; } .pinterest { background: #e60023; } .contact { background: #6b7280; }
.badge-buttons { display: flex; gap: 28px; justify-content: center; padding: 20px; }
</style>
<div class="control-section default">
<div class="sample_container badge-default">
<div class="badge-buttons" role="group" aria-label="Badge buttons">
<span class="ui-badge-host"><button type="button" id="update" class="ui-btn">Updates</button> @Html.UiBadge(new UiBadgeOptions { Content = "14", Color = UiBadgeColor.Info, Position = UiBadgePosition.Notification })</span>
<span class="ui-badge-host"><button type="button" id="task" class="ui-btn">Tasks</button> @Html.UiBadge(new UiBadgeOptions { Content = "48", Color = UiBadgeColor.Success, Position = UiBadgePosition.Notification })</span>
<span class="ui-badge-host"><button type="button" id="notify" class="ui-btn">Notifications</button> @Html.UiBadge(new UiBadgeOptions { Content = "99", Color = UiBadgeColor.Secondary, Position = UiBadgePosition.Notification })</span>
</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 BadgeController : Controller
{
// The page is Views/Badge/Default.cshtml; it draws what ViewData holds.
public ActionResult Default()
{
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 Badge is a component which is developed in pure CSS and designed in em relative units, so that badge will always be in relevant to the parent and makes the badge super easy to customize.
For Ex to increase the size of the badge, just increase the font-size the width and height will be adjusted.
There are 6 different types of badge. they are explained below.
- Default badge - To get the default badge, add
.e-badgeclass to the element. - Notification badge - To get the notification badge, add
.e-badge-notificationalong with.e-badgeand also make the wrapper elementposition: relative. - Circle badge - To get the circle badge, add the
.e-badge-circleclass along with.e-badge. - Pill Badge - To get the pill badge, add the
.e-badge-pillclass along with.e-badge. - Dot badge - To get the dot badge, add the
.e-badge-dotclass along with.e-badgeand also make the wrapper elementposition: relative.
The badge component supports two position. This is applicable only to Notification and dot badge.
- Top - It is the default position, so there is no additional class needed for top position.
- Bottom - To get the bottom badge, add
.e-.badge-bottomclass along with.e-badge.