Search results

Multiple Sidebar

Two Sidebars can be initialized in a web page with same main content. Sidebars can be initialized on right side or left side of the main content using position property.

The HTML element with class name e-main-content will be considered as the main content and both the Sidebars will behave as side content to this main content area of a web page.

Source
Preview
index.js
index.html
styles.css
ej.base.enableRipple(true);

//left Sidebar initialization
var leftSidebar= new ej.navigations.Sidebar({
     width: "200px",
     type:'Push'
});
leftSidebar.appendTo('#default');
//end of leftSidebar initialization

//Right Sidebar initialization
var rightSidebar = new ej.navigations.Sidebar({
    width: "200px",
    position:'Right',
    type:'Push'
 });
rightSidebar.appendTo('#default1');
//end of rightSidebar initialization

// Toggle(Open/Close) the left Sidebar
document.getElementById('toggle-btn').onclick = function () {
    leftSidebar.toggle();
};
// Toggle(Open/Close) the right Sidebar
document.getElementById('toggle-btn2').onclick = function () {
    rightSidebar.toggle();
};
<!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="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css" rel="stylesheet">
    <link href="//cdn.syncfusion.com/ej2/ej2-base/styles/material.css" rel="stylesheet">
    <link href="//cdn.syncfusion.com/ej2/ej2-buttons/styles/material.css" rel="stylesheet">
    <link href="//cdn.syncfusion.com/ej2/ej2-lists/styles/material.css" rel="stylesheet">
    <link href="//cdn.syncfusion.com/ej2/ej2-navigations/styles/material.css" rel="stylesheet">
    <link href="styles.css" rel="stylesheet">
    
    
<script src="https://cdn.syncfusion.com/ej2/dist/ej2.min.js" type="text/javascript"></script>
</head>

<body>
    
    <div id="container">
        <!-- left sidebar element -->
        <aside id="default">
            <div class="title"> Left Sidebar content</div>
        </aside>
        <!-- end of left sidebar element -->
        <!-- right sidebar element -->
        <aside id="default1">
            <div class="title">Right Sidebar content</div>
        </aside>
        <!-- end of right sidebar element -->
        <!-- main content declaration -->
        <div class="e-main-content" style="font-size:16px;padding:100px" ;>
            <p>Place your main content here.....</p>
            <button id="toggle-btn" class="e-btn">Toggle Sidebar1</button>
            <br>
            <br>
            <button id="toggle-btn2" class="e-btn">Toggle Sidebar2</button>
        </div>
        <!-- end of main content -->
    </div>



<script>
var ele = document.getElementById('container');
if(ele) {
    ele.style.visibility = "visible";
 }   
        </script>
<script src="index.js" type="text/javascript"></script>
</body></html>
#container {
	visibility: hidden;
  }
  
  #loader {
	color: #008cff;
	height: 40px;
	width: 30%;
	position: absolute;
	top: 45%;
	left: 45%;
  }
  
  .header {
	   width:100%;
	  height: 40px;
	  font-size:20px;
	  line-height: 40px;
	  font-weight: 500;
	  background: #eee;
	  display: inline-block;
  }
  
  .e-main-content{
	 text-align:center;
	height:100vh;
	 background: #f5f5f5; 
    }
  
  .title {
	  text-align: center;
	  font-size: 20px;
	  padding: 15px; 
    }
  
  
  #default,#default1 {
	  background-color: rgb(25, 118, 210);
	  color: #ffffff;
	  overflow:hidden;
    }