DevExtreme v23.2 is now available.

Explore our newest features/capabilities and share your thoughts with us.

Your search did not match any results.

Left or Right Position

Drawer is a dismissible or permanently visible panel that usually contains navigation elements.

To open or close the Drawer component in this demo, click the 'Hamburger' button. Each Drawer visibility change can adjust the layout in the following ways (see openedStateMode):

  • "push"
    The Drawer partially displaces the view.

  • "shrink"
    The view shrinks to accommodate the Drawer.

  • "overlap"
    The Drawer overlaps the view.

Use the radio buttons at the bottom of this demo module to try different layout modes. You can also change the Drawer's position and revealMode properties.

Note this demo's markup. The Drawer definition encloses the view content (the formatted text). The Drawer's own content (navigation links) is set by the template property. Finally, the toolbar markup is separate from other elements.

To get started with the DevExtreme Drawer component, refer to the following step-by-step tutorial: Getting Started with Navigation Drawer.

Backend API
$(() => { $('#content').html(text); const drawer = $('#drawer').dxDrawer({ opened: true, height: 400, closeOnOutsideClick: true, template() { const $list = $('<div>').width(200).addClass('panel-list dx-theme-typography-background-color'); return $list.dxList({ dataSource: navigation, hoverStateEnabled: false, focusStateEnabled: false, activeStateEnabled: false, }); }, }).dxDrawer('instance'); $('#toolbar').dxToolbar({ elementAttr: { class: 'dx-theme-background-color', }, items: [{ widget: 'dxButton', location: 'before', options: { icon: 'menu', stylingMode: 'text', onClick() { drawer.toggle(); }, }, }], }); $('#reveal-mode').dxRadioGroup({ items: ['slide', 'expand'], layout: 'horizontal', value: 'slide', onValueChanged(e) { drawer.option('revealMode', e.value); }, }); $('#opened-state-mode').dxRadioGroup({ items: ['push', 'shrink', 'overlap'], layout: 'horizontal', value: 'shrink', onValueChanged(e) { drawer.option('openedStateMode', e.value); $('#reveal-mode-option').css('visibility', e.value !== 'push' ? 'visible' : 'hidden'); }, }); $('#position-mode').dxRadioGroup({ items: ['left', 'right'], layout: 'horizontal', value: 'left', onValueChanged(e) { drawer.option('position', e.value); }, }); });
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>DevExtreme Demo</title> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script>window.jQuery || document.write(decodeURIComponent('%3Cscript src="js/jquery.min.js"%3E%3C/script%3E'))</script> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/23.2.5/css/dx.light.css" /> <script src="js/dx.all.js"></script> <script src="data.js"></script> <link rel="stylesheet" type="text/css" href="styles.css" /> <script src="index.js"></script> </head> <body class="dx-viewport"> <div class="demo-container"> <div class="flex-container"> <div id="toolbar"></div> <div id="drawer"> <div id="content" class="dx-theme-background-color"></div> </div> <div class="options"> <div class="caption">Options</div> <div class="options-container"> <div class="option"> <label>Opened state mode</label> <div id="opened-state-mode"></div> </div> <div class="option"> <label>Position</label> <div id="position-mode"></div> </div> <div id="reveal-mode-option" class="option"> <label>Reveal mode</label> <div id="reveal-mode"></div> </div> </div> </div> </div> </div> </body> </html>
.demo-container { overflow: visible; } .flex-container { display: flex; flex-direction: column; } .dx-drawer-content { display: flex; } #toolbar { box-shadow: 0 2px 8px 0 rgba(0, 0, 0, 0.12), 0 2px 2px 0 rgba(0, 0, 0, 0.08); padding: 5px 10px; z-index: 10000; } .panel-list { height: 400px; padding-top: 12px; } .options { padding: 20px; background-color: rgba(191, 191, 191, 0.15); } .options-container { display: flex; align-items: center; } .caption { font-size: 18px; font-weight: 500; } .option { margin-top: 10px; display: inline-block; margin-right: 50px; } label { font-weight: bold; } #content { padding: 0 24px; } #content h2 { font-size: 26px; }
const navigation = [ { id: 1, text: 'Products', icon: 'product' }, { id: 2, text: 'Sales', icon: 'money' }, { id: 3, text: 'Customers', icon: 'group' }, { id: 4, text: 'Employees', icon: 'card' }, { id: 5, text: 'Reports', icon: 'chart' }, ]; const text = ` <h2> <b>Drawer Demo</b> </h2> <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Penatibus et magnis dis parturient. Eget dolor morbi non arcu risus. Tristique magna sit amet purus gravida quis blandit. Auctor urna nunc id cursus metus aliquam eleifend mi in. Tellus orci ac auctor augue mauris augue neque gravida. Nullam vehicula ipsum a arcu. Nullam ac tortor vitae purus faucibus ornare suspendisse sed nisi. Cursus in hac habitasse platea dictumst. Egestas dui id ornare arcu. Dictumst vestibulum rhoncus est pellentesque elit ullamcorper dignissim.</p><p>Mauris rhoncus aenean vel elit scelerisque mauris pellentesque pulvinar. Neque volutpat ac tincidunt vitae semper quis lectus. Sed sed risus pretium quam vulputate dignissim suspendisse in. Urna nec tincidunt praesent semper feugiat nibh sed pulvinar. Ultricies lacus sed turpis tincidunt id aliquet risus feugiat. Amet cursus sit amet dictum sit amet justo donec enim. Vestibulum rhoncus est pellentesque elit ullamcorper. Id aliquet risus feugiat in ante metus dictum at. </p>`;