Search results


The Sidebar component’s expand behaviour can be modified based on the purpose of use.

Expanding types of Sidebar

The Sidebar can be set to initialize based on four different types that are consistent with the main component as explained below.

Item Description
Over Sidebar floats over the main content area.
Push Sidebar pushes the main content area to appear side-by-side, and shrinks the main content within the screen width.
Slide Sidebar translates the x and y positions of main content area based on the Sidebar width. The main content area will not be adjusted within the screen width.
Auto Sidebar with Over type in mobile resolution, and Push type in other higher resolutions.

Auto is the default expand mode.

In the following sample, the types of Sidebar are demonstrated.

   var defaultSidebar = new ej.navigations.Sidebar({
        type: "Push",
        target: document.querySelector('.maincontent')
    //end of sidebar initialization

    //toggle button initialization

    var togglebtn = new ej.buttons.Button({iconCss: 'e-icons burg-icon', isToggle: true, content:'Open'}, '#toggle');

    //Click Event.
    document.getElementById('toggle').onclick = function(){
        if (document.getElementById('toggle').classList.contains('e-active')) {
            togglebtn.content = 'Close';
        } else {
            togglebtn.content = 'Open';

    // Close the sidebar
    document.getElementById('close').onclick = function() => {
        togglebtn.content = 'Open'

    var typeOver = new ej.buttons.RadioButton({ label: 'Over', name: 'state', checked: true, change: Change });

    //unchecked state.
    var typePush = new ej.buttons.RadioButton({ label: 'Push', name: 'state', change: Change });

    var typeSlide = new ej.buttons.RadioButton({ label: 'Slide', name: 'state', change: Change });

    //unchecked state.
    var typeAuto = new ej.buttons.RadioButton({ label: 'Auto', name: 'state', change: Change });

    function Change(args) {
        if ( == "over") {
            defaultSidebar.type = "Over"
        } else if ( == "push") {
            defaultSidebar.type = "Push"
        else if ( == "slide") {
            defaultSidebar.type = "Slide"
        else {
            defaultSidebar.type = "Auto"
<!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">
    <link href="//" rel="stylesheet">
<script src="//" type="text/javascript"></script>

    <div id="container">
        <aside id="default-sidebar">
            <div class="title"> Sidebar content</div>
            <div id="list"></div>
            <div class="sub-title">
                Click the button to close the Sidebar.
            <div class="center-align">
                <button id="close" class="e-btn close-btn">Close Sidebar</button>
        <!-- end of sidebar element -->
        <!-- main content declaration -->

        <div id="head">
            <button id="toggle" class="e-btn e-info"></button>
            <div class="maincontent" style="height:335px;border:1px solid gray">
                <div class="content">
                    <div class="title">Main content</div>
                    <div class="sub-title">
                        <div class="radiobutton">
                            <input type="radio" id="over">
                        <div class="radiobutton">
                            <input type="radio" id="push">
                        <div class="radiobutton">
                            <input type="radio" id="slide">
                        <div class="radiobutton">
                            <input type="radio" id="auto">

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