Multiple sidebar in EJ2 TypeScript Sidebar control

2 May 20234 minutes to read

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.

import { Sidebar } from '@syncfusion/ej2-navigations';
import { enableRipple } from '@syncfusion/ej2-base';

let leftSidebar: Sidebar = new Sidebar({
   width: "200px",

//end of leftSidebar initialization

let rightSidebar: Sidebar = new Sidebar({
   width: "200px",
//end of rightSidebar initialization

// Toggle(Open/Close) the Sidebar1
document.getElementById('toggle-btn').onclick = function () {
// Toggle(Open/Close) the Sidebar2
document.getElementById('toggle-btn2').onclick = function () {
<!DOCTYPE html>
<html lang="en">

    <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=""></script>
    <script src="systemjs.config.js"></script>
<script src="" type ="text/javascript"></script>

    <div id='loader'>LOADING....</div>
    <div id='container'>
        <!-- left sidebar element -->
        <aside id="default">
            <div class="title"> Left Sidebar content</div>
        <!-- end of left sidebar element -->
        <!-- right sidebar element -->
        <aside id="default1">
            <div class="title">Right Sidebar content</div>
        <!-- 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>
            <button id='toggle-btn2' class='e-btn'>Toggle Sidebar2</button>
        <!-- end of main content -->