Docking sidebar in EJ2 JavaScript Sidebar control

2 May 20237 minutes to read

Dock state of the Sidebar reserves some space on the page that always remains in a visible state when the Sidebar is collapsed. It is used to show the short term of a content like icons alone instead of lengthy text. To achieve this , set enableDock as true along with required dockSize.

In the following sample, the list item has icon with text representation. On dock state, only icons in list will be visible to represent the hint of the hidden text content.

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

    document.getElementById('toggle').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">
        <!-- sidebar element declaration -->
        <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>
        <!-- end of sidebar element -->
        <!-- main content declaration -->
        <div id="main-content container-fluid col-md-12 ">
            <div class="title">Main content</div>
            <div class="sub-title"> Click the expand icon to open and collapse icons to close the Sidebar.</div>
        <!--end of main content -->

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

See Also