Multiple sidebar in same position in EJ2 JavaScript Sidebar control

2 May 20238 minutes to read

You can initialize Sidebar at the left positions by using the position property. It will automatically adjust the width of the main content.

You can also initialize the another sidebar on the same position by adjusting the width of the first sidebar.

The following example demonstrate how to align the multiple sidebar on the same position.


//Dock Sidebar initialization
var dockBar= new ej.navigations.Sidebar({
        width: '220px',
        dockSize: '72px',
        enableDock: true,
//end of DockSidebar initialization

//Default Sidebar initialization
var defaultSidebar = new ej.navigations.Sidebar({
//end of DefaultSidebar initialization

//switch the expand and collapse state
document.getElementById('buttonClick').onclick = function () {
<!DOCTYPE html><html lang="en"><head>
    <title>Essential JS 2 Sidebar</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="Typescript UI Controls">
    <meta name="author" content="Syncfusion">
    <link href="" rel="stylesheet">
    <link href="" rel="stylesheet">
    <link href="" rel="stylesheet">
    <link href="" rel="stylesheet">
    <link href="" rel="stylesheet">
    <link href="styles.css" rel="stylesheet">
<script src="" type="text/javascript"></script>
<script src="" type ="text/javascript"></script>

    <div id="container">
        <!-- first sidebar element -->
        <aside id="default-sidebar">
            <div class="sub-title">
              <h3> First Sidebar</h3>
                Place your primary content here.
           <!-- dock sidebar element -->
        <aside id="dockSidebar">
            <div class="dock">
                    <li class="sidebar-item" id="toggle">
                        <span class="e-icons expand"></span>
                        <span class="e-text" title="menu">Menu</span>
                    <li class="sidebar-item">
                        <span class="e-icons home"></span>
                        <span class="e-text" title="home">Home</span>
                    <li class="sidebar-item">
                        <span class="e-icons profile"></span>
                        <span class="e-text" title="profile">Profile</span>
                    <li class="sidebar-item">
                        <span class="e-icons info"></span>
                        <span class="e-text" title="info">Info</span>
                    <li class="sidebar-item">
                        <span class="e-icons settings"></span>
                        <span class="e-text" title="settings">Settings</span>
        <!-- main content declaration -->
        <div class="e-main-content container-fluid col-md-12">
            <div class="title">Main content</div>
            <div class="sub-title">
                <p>Click the radio button to switch the sidebar position</p>
                <div class="center-align">
                    <div class="column">
                        <button class="e-btn e-info" id="buttonClick">Open/close hidden Sidebar</button>
        <!-- end of main content -->

var ele = document.getElementById('container');
if(ele) { = "visible";
<script src="index.js" type="text/javascript"></script>