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
<dx-toolbar [items]="toolbarContent"> </dx-toolbar> <dx-drawer [openedStateMode]="selectedOpenMode" [position]="selectedPosition" [revealMode]="selectedRevealMode" template="template" [opened]="false" [height]="400" [closeOnOutsideClick]="true"> <div *dxTemplate="let data of 'template'"> <dx-list class="panel-list dx-theme-accent-as-background-color" [hoverStateEnabled]="false" [activeStateEnabled]="false" [focusStateEnabled]="false" [dataSource]="navigation"> </dx-list> </div> <div id="content" class="dx-theme-background-color" [innerHTML]="text"></div> </dx-drawer> <div class="options"> <div class="caption">Options</div> <div class="option"> <label>Opened state mode</label> <dx-radio-group [(value)]="selectedOpenMode" [items]="showModes" layout="horizontal"> </dx-radio-group> </div> <div class="option"> <label>Position</label> <dx-radio-group [(value)]="selectedPosition" [items]="positionModes" layout="horizontal"> </dx-radio-group> </div> <div *ngIf="selectedOpenMode !== 'push'" class="option"> <label>Reveal mode</label> <dx-radio-group [(value)]="selectedRevealMode" [items]="showSubmenuModes" layout="horizontal"> </dx-radio-group> </div> </div>
import { NgModule, Component, ViewChild, enableProdMode } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { List, Service } from './app.service'; import { DxDrawerComponent, DxDrawerModule, DxListModule, DxRadioGroupModule, DxToolbarModule } from 'devextreme-angular'; if (!/localhost/.test(document.location.host)) { enableProdMode(); } @Component({ selector: 'demo-app', templateUrl: 'app/app.component.html', styleUrls: ['app/app.component.css'], providers: [Service], preserveWhitespaces: true }) export class AppComponent { @ViewChild(DxDrawerComponent) drawer: DxDrawerComponent; navigation: List[]; showSubmenuModes: string[] = ['slide', 'expand']; positionModes: string[] = ['top', 'bottom']; showModes: string[] = ['push', 'shrink', 'overlap']; selectedOpenMode: string = 'shrink'; selectedPosition: string = 'top'; selectedRevealMode: string = 'expand'; text: string; elementAttr: any; constructor(service: Service) { this.text = service.getContent(); this.navigation = service.getNavigationList(); } toolbarContent = [{ widget: 'dxButton', location: 'before', options: { icon: 'menu', onClick: () => this.drawer.instance.toggle() } }]; } @NgModule({ imports: [ BrowserModule, DxDrawerModule, DxListModule, DxRadioGroupModule, DxToolbarModule ], declarations: [AppComponent], bootstrap: [AppComponent] }) export class AppModule { } platformBrowserDynamic().bootstrapModule(AppModule)
::ng-deep .dx-toolbar { background-color: rgba(191, 191, 191, .15); padding: 5px 10px; } ::ng-deep .dx-list-item-icon-container, ::ng-deep .dx-toolbar-before { width: 36px; padding-right: 0px !important; text-align: center; } ::ng-deep .dx-list-item-content { padding-left: 10px !important; } ::ng-deep .dx-button { background-color: rgba(191, 191, 191, -0.15); border: none; } ::ng-deep .dx-drawer-shrink #content { overflow: hidden; transition: all 0.4s ease-out; column-width: 900px; } ::ng-deep .dx-drawer-shrink.dx-drawer-opened #content { column-width: 300px; margin-right: -10px; } ::ng-deep .panel-list { height: 200px; } ::ng-deep .panel-list .dx-list-item { color: #fff; text-align: center; border-top: 1px solid rgba(221, 221, 221, .2); } ::ng-deep .options { padding: 20px; background-color: rgba(191, 191, 191, .15); } ::ng-deep .caption { font-size: 18px; font-weight: 500; } ::ng-deep .option { margin-top: 10px; display: inline-block; margin-right: 50px; } ::ng-deep label { font-weight: bold; } ::ng-deep #content { height: 100%; padding: 10px 20px; } ::ng-deep #content h2 { font-size: 26px; }
import { Injectable } from '@angular/core'; export class List { id: number; text: string; } let navigation: List[] = [ { id: 1, text: "Products" }, { id: 2, text: "Sales" }, { id: 3, text: "Customers" }, { id: 4, text: "Employees" }, { id: 5, text: "Reports" } ]; let text: string = ` <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> `; @Injectable() export class Service { getNavigationList(): List[] { return navigation; } getContent(): string { return text; } }
// In real applications, you should not transpile code in the browser. You can see how to create your own application with Angular and DevExtreme here: // https://github.com/DevExpress/devextreme-angular/blob/master/README.md System.config({ transpiler: 'ts', typescriptOptions: { module: "commonjs", emitDecoratorMetadata: true, experimentalDecorators: true }, meta: { 'typescript': { "exports": "ts" } }, paths: { 'npm:': 'https://unpkg.com/' }, map: { 'ts': 'npm:plugin-typescript@7.0.6/lib/plugin.js', 'typescript': 'npm:typescript@2.2.2/lib/typescript.js', '@angular/core': 'npm:@angular/core@7.1.3/bundles/core.umd.js', '@angular/common': 'npm:@angular/common@7.1.3/bundles/common.umd.js', '@angular/compiler': 'npm:@angular/compiler@7.1.3/bundles/compiler.umd.js', '@angular/platform-browser': 'npm:@angular/platform-browser@7.1.3/bundles/platform-browser.umd.js', '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic@7.1.3/bundles/platform-browser-dynamic.umd.js', '@angular/http': 'npm:@angular/http@7.1.3/bundles/http.umd.js', '@angular/router': 'npm:@angular/router@7.1.3/bundles/router.umd.js', '@angular/forms': 'npm:@angular/forms@7.1.3/bundles/forms.umd.js', '@angular/common/http': 'npm:@angular/common@7.1.3/bundles/common-http.umd.js', 'tslib': 'npm:tslib/tslib.js', 'rxjs': 'npm:rxjs@6.3.3', 'rxjs/operators': 'npm:rxjs@6.3.3/operators', 'devextreme': 'npm:devextreme@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', 'devextreme-angular': 'npm:devextreme-angular@19.1' }, packages: { 'app': { main: './app.component.ts', defaultExtension: 'ts' }, 'devextreme': { defaultExtension: 'js' }, 'rxjs': { main: 'index.js', defaultExtension: 'js' }, 'rxjs/operators': { main: 'index.js', defaultExtension: 'js' }, 'devextreme-angular': { main: 'index.js', defaultExtension: 'js' } } });
<!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" /> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/19.1.3/css/dx.common.css" /> <link rel="dx-theme" data-theme="generic.light" href="https://cdn3.devexpress.com/jslib/19.1.3/css/dx.light.css" /> <link rel="dx-theme" data-theme="ios7.default" href="https://cdn3.devexpress.com/jslib/19.1.3/css/dx.ios7.default.css" /> <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" /> <script src="https://unpkg.com/core-js@2.4.1/client/shim.min.js"></script> <script src="https://unpkg.com/zone.js@0.6.25/dist/zone.js"></script> <script src="https://unpkg.com/reflect-metadata@0.1.3/Reflect.js"></script> <script src="https://unpkg.com/systemjs@0.21.3/dist/system.js"></script> <script src="config.js"></script> <script> System.import('app').catch(console.error.bind(console)); </script> </head> <body class="dx-viewport"> <div class="demo-container"> <demo-app>Loading...</demo-app> </div> </body> </html>