Usage.cshtml
SidebarWithMenu.cshtml
SidebarController.cs
Setup.cshtml
Copy
@Html.UiToolbar(new UiToolbarOptions { Id = "menuToolbar", Items = (List<UiToolbarItem>)ViewData["MenuToolItems"], OnClick = "toggleSidebar" })
<style>
.sb-toolbar .ui-toolbar { border: 1px solid var(--ui-border); border-bottom: 0; border-radius: 4px 4px 0 0; }
.sb-frame { position: relative; display: flex; height: 380px; overflow: hidden; border: 1px solid var(--ui-border); border-radius: 0 0 4px 4px; background: var(--ui-surface); }
.sb-frame.sb-alone { border-radius: 4px; }
.sb-frame > .ui-sidebar { z-index: 20; }
.sb-main { flex: 1 1 auto; min-width: 0; overflow: auto; padding: 15px; box-sizing: border-box; font-size: 14px; }
.sb-side { padding: 15px; }
.e-folder-name { font-size: 16px; font-weight: 600; padding-left: 6px; }
.e-user-name { font-size: 14px; padding-right: 6px; }
.e-user-avatar { display: inline-flex; width: 32px; height: 32px; align-items: center; justify-content: center; border-radius: 50%; background: var(--ui-accent); color: var(--ui-on-accent); font-weight: 600; }
.sb-mail, .sb-list { list-style: none; margin: 0; padding: 0; }
.sb-mail li { display: grid; grid-template-columns: 40px 1fr; column-gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--ui-border); }
.sb-mail .e-avatar { grid-row: span 3; align-self: center; width: 36px; height: 36px; border-radius: 50%; background: var(--ui-row-hover-bg); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; }
.sb-mail .e-list-item-header { font-weight: 600; }
.sb-mail .e-list-content { color: var(--ui-text); }
.sb-mail .e-list-text { color: var(--ui-muted); font-size: 12px; }
.sb-heading { font-size: 18px; font-weight: 600; margin: 0 0 8px; }
.sb-paragraph { margin: 0 0 16px; text-align: justify; }
.sb-list li button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 0; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.sb-list li button:hover { background: var(--ui-row-hover-bg); }
.sb-list li button[aria-current="true"] { background: var(--ui-row-hover-bg); font-weight: 600; }
.sb-list .e-icons { flex: none; width: 24px; height: 24px; font-size: 20px; }
.sb-list .sb-text { white-space: nowrap; overflow: hidden; }
.ui-sidebar-dock:not(.ui-sidebar-open) .sb-text { display: none; }
.sb-sub { list-style: none; margin: 0; padding: 0 0 0 34px; }
.sb-sub[hidden], .ui-sidebar-dock:not(.ui-sidebar-open) .sb-sub { display: none; }
</style>
@using Lumen.UI.Mvc.Demo.Controllers
<div class="control-section">
<div class="sb-toolbar">
@Html.UiToolbar(new UiToolbarOptions { Id = "menuToolbar", Items = (List<UiToolbarItem>)ViewData["MenuToolItems"], OnClick = "toggleSidebar" })
</div>
<div class="sb-frame">
@using (Html.BeginUiSidebar(new UiSidebarOptions { Id = "menuSidebar", Contained = true, Type = UiSidebarType.Push, EnableDock = true, DockSize = "50px", Width = "220px", IsOpen = true, CssClass = "sidebar-menu" }))
{
<ul class="sb-list dock-menu" id="dockMenu">
@foreach (var group in (List<NavigationDemoController.SidebarMenuGroup>)ViewData["Items"])
{
<li>
<button type="button" title="@group.Text" aria-haspopup="true" aria-expanded="false"><span class="@group.IconCss" aria-hidden="true"></span><span class="sb-text">@group.Text</span></button>
<ul class="sb-sub" hidden>
@foreach (string sub in group.Items)
{
<li><button type="button">@sub</button></li>
}
</ul>
</li>
}
</ul>
}
<div class="sb-main main-content" id="maintext">
<div class="content">
<div class="sb-heading">Responsive Sidebar with Menu</div>
<p class="sb-paragraph">The ASP.NET MVC Sidebar is an expandable and collapsible component that typically acts as a side container to place primary or secondary content alongside the main content. It provides flexible options that can be shown and hidden based on user interactions. Any type of HTML content or component can be placed in the ASP.NET Core Sidebar for quick access and easy navigation, like quick references, menus, lists, and tree views.</p>
<div class="sb-heading">HTML side content position</div>
<p class="sb-paragraph">The ASP.NET MVC Sidebar component positions its content to the left or right side of the main content area. This option allows the placement of two sidebars on a page, one on the left and one on the right, to show primary and secondary content simultaneously.</p>
<div class="sb-heading">Responsive sidebar</div>
<p class="sb-paragraph">Auto closing the ASP.NET MVC Sidebar component content, makes the main content area more readable.</p>
</div>
</div>
</div>
</div>
<script>
// Syncfusion: the Menu button of the Toolbar toggles the Sidebar
function toggleSidebar(item) {
if (item.id === 'menu') { window.Lumen.get('menuSidebar').toggle(); }
}
</script>
<script>
// Syncfusion: a vertical Menu; a click on an item opens its sub items under it (they stay out of the docked strip)
document.getElementById('dockMenu').addEventListener('click', function (e) {
var button = e.target.closest('button');
var sub = button && button.nextElementSibling;
if (!sub || sub.tagName !== 'UL') { return; }
sub.hidden = !sub.hidden;
button.setAttribute('aria-expanded', sub.hidden ? 'false' : 'true');
});
</script>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using Lumen.UI.Mvc;
namespace YourApp.Controllers
{
public class SidebarController : Controller
{
// The page is Views/Sidebar/SidebarWithMenu.cshtml; it draws what ViewData holds.
public ActionResult SidebarWithMenu()
{
ViewData["MenuToolItems"] = new List<UiToolbarItem>
{
new UiToolbarItem { Id = "menu", IconCss = "e-icons e-menu", TooltipText = "Menu" },
new UiToolbarItem { Type = UiToolbarItemType.Input, HtmlContent = new HtmlString("<div class='e-folder'><div class='e-folder-name'>Navigation Pane</div></div>") }
};
ViewData["Items"] = new List<SidebarMenuGroup>
{
new SidebarMenuGroup { Text = "Overview", IconCss = "e-icons e-home", Items = new List<string> { "All Data", "Category2", "Category3" } },
new SidebarMenuGroup { Text = "Notification", IconCss = "e-icons e-annotation-edit", Items = new List<string> { "Change Profile", "Add Name", "Add Details" } },
new SidebarMenuGroup { Text = "Info", IconCss = "e-icons e-comment", Items = new List<string> { "Message", "Facebook", "Twitter" } },
new SidebarMenuGroup { Text = "Comments", IconCss = "e-icons e-comment", Items = new List<string> { "Category1", "Category2", "Category3" } },
new SidebarMenuGroup { Text = "Bookmarks", IconCss = "e-icons e-folder", Items = new List<string> { "All Comments", "Add Comments", "Delete Comments" } },
new SidebarMenuGroup { Text = "Images", IconCss = "e-icons e-zoom-in", Items = new List<string> { "Add Name", "Add Mobile Number" } },
new SidebarMenuGroup { Text = "Users", IconCss = "e-icons e-mouse-pointer", Items = new List<string> { "Mobile User", "Laptop User", "Desktop User" } },
new SidebarMenuGroup { Text = "Settings", IconCss = "e-icons e-pan", Items = new List<string> { "Change Profile", "Add Name", "Add Details" } },
new SidebarMenuGroup { Text = "Info", IconCss = "e-icons e-home", Items = new List<string> { "Facebook", "Mobile" } }
};
return View();
}
/// <summary>A top item of the Sidebar with Menu sample's menu.</summary>
public class SidebarMenuGroup
{
public string Text { get; set; }
public string IconCss { get; set; }
public List<string> Items { get; set; }
}
}
}
@* 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>