Your search did not match any results.

Left or Right Position


The Drawer is a dismissible or permanently visible panel used for navigation in responsive web applications. On opening, the Drawer can interact with the view in several modes: "shrink", "push", and "overlap". The view's content (an HTML string in this demo) is part of the Drawer's markup. The Drawer's content is defined using a template. Note that the Drawer does not interact with the toolbar because the latter is not defined in the Drawer's markup.

In this demo, you can use radio buttons under the Drawer to change its position and behavior.

Copy to CodeSandBox
import React from 'react'; import Drawer from 'devextreme-react/drawer'; import RadioGroup from 'devextreme-react/radio-group'; import Toolbar from 'devextreme-react/toolbar'; import HTMLReactParser from 'html-react-parser'; import { text } from './data.js'; import NavigationList from './NavigationList.js'; class App extends React.Component { constructor() { super(); this.state = { opened: true, openedStateMode: 'shrink', revealMode: 'slide', position: 'left' }; this.toolbarItems = [{ widget: 'dxButton', location: 'before', options: { icon: 'menu', onClick: () => this.setState({ opened: !this.state.opened }) } }]; this.onOpenedStateModeChanged = this.onOpenedStateModeChanged.bind(this); this.onRevealModeChanged = this.onRevealModeChanged.bind(this); this.onPositionChanged = this.onPositionChanged.bind(this); this.onPositionChanged = this.onPositionChanged.bind(this); this.onOutsideClick = this.onOutsideClick.bind(this); } onOpenedStateModeChanged({ value }) { this.setState({ openedStateMode: value }); } onRevealModeChanged({ value }) { this.setState({ revealMode: value }); } onPositionChanged({ value }) { this.setState({ position: value }); } onOutsideClick() { this.setState({ opened: false }); } render() { const { opened, openedStateMode, position, revealMode } = this.state; return ( <React.Fragment> <Toolbar items={this.toolbarItems } /> <Drawer opened={opened} openedStateMode={openedStateMode} position={position} revealMode={revealMode} component={NavigationList} closeOnOutsideClick={this.onOutsideClick} height={400}> <div id="content" className="dx-theme-background-color"> {HTMLReactParser(text)} </div> </Drawer> <div className="options"> <div className="caption">Options</div> <div className="option"> <label>Opened state mode</label> <RadioGroup items={['push', 'shrink', 'overlap']} layout="horizontal" value={openedStateMode} onValueChanged={this.onOpenedStateModeChanged} /> </div> {' '} <div className="option"> <label>Position</label> <RadioGroup items={['left', 'right']} layout="horizontal" value={position} onValueChanged={this.onPositionChanged} /> </div> {' '} {openedStateMode !== 'push' && (<div className="option"> <label>Reveal mode</label> <RadioGroup items={['slide', 'expand']} layout="horizontal" value={revealMode} onValueChanged={this.onRevealModeChanged} /> </div>)} </div> </React.Fragment> ); } } export default App;
import React from 'react'; import ReactDOM from 'react-dom'; import App from './App.js'; ReactDOM.render( <App />, document.getElementById('app') );
<!DOCTYPE html> <html> <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" /> <link rel="stylesheet" type="text/css" href="" /> <link rel="stylesheet" type="text/css" href="" /> <link rel="stylesheet" type="text/css" href="styles.css" /> <script src=""></script> <script src=""></script> <script type="text/javascript" src="config.js"></script> <script type="text/javascript"> System.import('./index.js'); </script> </head> <body class="dx-viewport"> <div class="demo-container"> <div id="app"></div> </div> </body> </html>
.dx-toolbar { background-color: rgba(191, 191, 191, .15); padding: 5px 10px; } .dx-list-item-icon-container, .dx-toolbar-before { width: 36px; padding-right: 0px !important; text-align: center; } .dx-list-item-content { padding-left: 10px !important; } .dx-button { background-color: rgba(191, 191, 191, -0.15); border: none; } .panel-list { height: 400px; } .dx-drawer-expand.dx-drawer-right .panel-list { float: right; } .panel-list .dx-list-item { color: #fff; border-top: 1px solid rgba(221, 221, 221, .2); } .panel-list .dx-list-item .dx-icon { color: #fff !important; } .options { padding: 20px; background-color: rgba(191, 191, 191, .15); } .caption { font-size: 18px; font-weight: 500; } .option { margin-top: 10px; display: inline-block; margin-right: 50px; } label { font-weight: bold; } #content { height: 100%; padding: 10px 20px; } #content h2 { font-size: 26px; }
export 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' } ]; export 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>';
System.config({ transpiler: 'plugin-babel', meta: { }, paths: { 'npm:': '' }, defaultExtension: 'js', map: { 'react': 'npm:react@16/umd/react.development.js', 'react-dom': 'npm:react-dom@16/umd/react-dom.development.js', 'prop-types': 'npm:prop-types/prop-types.js', 'html-react-parser': 'npm:html-react-parser@latest/dist/html-react-parser.min.js', 'devextreme': 'npm:devextreme@20.1', 'devextreme-react': 'npm:devextreme-react@20.1', 'jszip': 'npm:jszip@3.1.3/dist/jszip.min.js', 'quill': 'npm:quill@1.3.7/dist/quill.js', 'devexpress-diagram': 'npm:devexpress-diagram@1.0.17', 'devexpress-gantt': 'npm:devexpress-gantt@1.0.10', // SystemJS plugins 'plugin-babel': 'npm:systemjs-plugin-babel@0/plugin-babel.js', 'systemjs-babel-build': 'npm:systemjs-plugin-babel@0/systemjs-babel-browser.js' }, packages: { 'devextreme': { defaultExtension: 'js' }, 'devextreme-react': { main: 'index.js' }, 'devextreme/events/utils': { main: 'index' }, 'devextreme/events': { main: 'index' }, }, babelOptions: { sourceMaps: false, stage0: true, react: true } });