Open and close the Sidebar in Blazor Sidebar Component

27 Oct 20211 minute to read

Opening and closing the Sidebar can be achieved with IsOpen property.

In the following sample, IsOpen property has been used to show or hide the Sidebar on button click.

@using Syncfusion.Blazor.Navigations
@using Syncfusion.Blazor.Buttons

<div id="header" style="height:45px;text-align: center;color:white;background-color:midnightblue;font-size:1.2rem;line-height:45px;">

<SfSidebar @ref="sidebarObj" Width="250px" @bind-IsOpen="SidebarToggle">
        <div style="text-align: center;" class="text-content">
                <SfButton @onclick="Close" CssClass="e-btn close-btn">Close Sidebar</SfButton>

<div class="text-content" style="text-align: center;">
    <div>Main content</div>
        <SfButton @onclick="Toggle" IsToggle="true" CssClass="e-btn e-info">Toggle Sidebar</SfButton>

    SfSidebar sidebarObj;
    public bool SidebarToggle = false;
    public void Close()
        SidebarToggle = false;
    public void Toggle()
        SidebarToggle = !SidebarToggle;

    .e-sidebar {
        background-color: #f8f8f8;
        color: black;

    .text-content {
        font-size: 1.5rem;
        padding: 3rem;

    .main > div {
        padding: 0px !important;

Opening and Closing Blazor Sidebar