Your search did not match any results.
Drawer

Top or Bottom Position

Documentation

This example shows a Drawer that opens from the top or bottom of the view. You can use the radio buttons under the Drawer to change its position and behavior in relation to the view.

Copy to CodeSandBox
Apply
Reset
import React from 'react'; import { Drawer, RadioGroup, Toolbar } from 'devextreme-react'; 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: false, openedStateMode: 'shrink', revealMode: 'expand', position: 'top' }; 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); } onOpenedStateModeChanged({ value }) { this.setState({ openedStateMode: value }); } onRevealModeChanged({ value }) { this.setState({ revealMode: value }); } onPositionChanged({ value }) { this.setState({ position: value }); } render() { const { opened, openedStateMode, position, revealMode } = this.state; return ( <React.Fragment> <Toolbar items={this.toolbarItems} /> <Drawer opened={opened} openedStateMode={openedStateMode} position={position} component={NavigationList} revealMode={revealMode} height={400} maxSize={200} closeOnOutsideClick={true}> <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={['top', 'bottom']} 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="https://cdn3.devexpress.com/jslib/19.1.6/css/dx.common.css" /> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/19.1.6/css/dx.light.css" /> <link rel="stylesheet" type="text/css" href="styles.css" /> <script src="https://unpkg.com/core-js@2.4.1/client/shim.min.js"></script> <script src="https://unpkg.com/systemjs@0.21.3/dist/system.js"></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; } .dx-drawer-shrink #content { overflow: hidden; transition: all 0.4s ease-out; column-width: 900px; } .dx-drawer-shrink.dx-drawer-opened #content{ column-width: 300px; margin-right: -10px; } .panel-list { height: 200px; pointer-events: none; } .panel-list .dx-list-item { color: #fff; text-align: center; border-top: 1px solid rgba(221, 221, 221, .2); } .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' }, { id: 2, text: 'Sales' }, { id: 3, text: 'Customers' }, { id: 4, text: 'Employees' }, { id: 5, text: 'Reports' } ]; 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', paths: { 'npm:': 'https://unpkg.com/' }, 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@19.1', 'devextreme-react': 'npm:devextreme-react@19.1', 'jszip': 'npm:jszip@3.1.3/dist/jszip.min.js', 'quill': 'npm:quill@1.3.6/dist/quill.js', 'devexpress-diagram': 'npm:devexpress-diagram', // 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' } }, babelOptions: { sourceMaps: false, stage0: true, react: true } });