Is there a way to achieve a Gmail-style side menu in a Blazor Server application (using .NET 6 Blazor Server) where only icons are initially displayed, and hovering over the menu expands it to show names without reducing the main body section width? Below are my current menu setup and CSS files.
Below is the current menu layout:
View Left Nav Menu
Showcased below is the NavMenu.razor content:
<main class="sidebarmain">
<div class="flex-shrink-0 p-3" style="width: 280px;">
<a href="/" class="d-flex align-items-center pb-3 mb-3 link-dark text-decoration-none border-bottom">
<svg class="bi me-2" width="30" height="24">
<use xlink:href="#bootstrap"></use>
</svg>
@*<span class="fs-5 fw-semibold">Collapsible</span>*@
</a>
<ul class="list-unstyled ps-0">
<li class="mb-1">
<button class="btn btn-toggle align-items-center rounded" data-bs-toggle="collapse" data-bs-target="#home-collapse" aria-expanded="true">
Home
</button>
<div class="collapse show" id="home-collapse">
<ul class="btn-toggle-nav list-unstyled fw-normal pb-1 small">
@* <li>
<a href="/" class="link-dark rounded">Dashboard</a>
</li> *@
<li>
<NavLink href="/" class="link-dark rounded">Dashboard</NavLink>
</li>
</ul>
</div>
</li>
... // Additional menu items
</ul>
</div>
</main>
In addition, here is the MainLayout.razor code snippet:
@inherits LayoutComponentBase
... // Code sections for toggling and handling collapsible menu
Displaying next is the sidebar.css file contents:
body {
min-height: 100vh;
min-height: -webkit-fill-available;
... // CSS properties for styling the sidebar
If you're interested, take a look at the Gmail left menu styled using Bootstrap 5:
Check out Gmail-style Left Menu
Update:
I've made progress on displaying just icons initially but expanding the sidebar fully over the main area remains a challenge.
Sidebar with Icon-only Display
Additional CSS has been added to enhance the display:
/* Sidebar styles */
.sidebar {
position: fixed; /* Fixed positioning for the sidebar */
top: 0 !important;
left: 0;
height: 100% !important; /* Full height coverage */
z-index: 100 !important; /* Ensure visibility above other content */
background-color: #ced0da; /* Background color definition */
transition: width 0.3s;
}
... // More CSS rules for adjusting sidebar width and appearance on hover