React Drawer Props

This section describes properties that configure the Drawer UI component's contents, behavior and appearance.

activeStateEnabled

Specifies whether the UI component changes its visual state as a result of user interaction.

Type:

Boolean

Default Value: false

The UI component switches to the active state when users press down the primary mouse button. When this property is set to true, the CSS rules for the active state apply. You can change these rules to customize the component.

Use this property when you display the component on a platform whose guidelines include the active state change for UI components.

animationDuration

Specifies the duration of the drawer's opening and closing animation (in milliseconds). Applies only if animationEnabled is true.

Type:

Number

Default Value: 400

animationEnabled

Specifies whether to use an opening and closing animation.

Type:

Boolean

Default Value: true

closeOnOutsideClick

Specifies whether to close the drawer if a user clicks or taps the view area.

Type:

Boolean

|

Function

Function parameters:
event:

Event (jQuery or EventObject)

The raised event. It is a EventObject or a jQuery.Event when you use jQuery.

Return Value:

Boolean

true if the UI component should be closed; otherwise false.

Default Value: false

The function passed to this property enables you to specify a custom condition for UI component closing. For instance, you can prevent closing until a user clicks a specific element on the view:

jQuery
JavaScript
$(function() {
    $("#drawerContainer").dxDrawer({
        // ...
        closeOnOutsideClick: function(e) {
            return e.target === $("#someElement").get()[0];
        }
    });
});
Angular
TypeScript
HTML
import { DxDrawerModule } from "devextreme-angular";
// ...
export class AppComponent {
    // ...
    closeOnOutsideClick(e) {
        return e.target === document.getElementById("someElement");
    }
}
@NgModule({
     imports: [
         // ...
         DxDrawerModule
     ],
     // ...
 })
<dx-drawer ...
    [closeOnOutsideClick]="closeOnOutsideClick">
</dx-drawer>
Vue
App.vue
<template>
    <DxDrawer ....
        :close-on-outside-click="closeOnOutsideClick">
    </DxDrawer>
</template>

<script>
import 'devextreme/dist/css/dx.light.css';

import DxDrawer from 'devextreme-vue/drawer';

export default {
    components: {
        DxDrawer
    },
    methods: {
        closeOnOutsideClick (e) {
            return e.target === document.getElementById("someElement");
        }
    }
}
</script>
React
App.js
import React from 'react';
import 'devextreme/dist/css/dx.light.css';

import Drawer from 'devextreme-react/drawer';

const closeOnOutsideClick = (e) => {
    return e.target === document.getElementById("someElement");
};

export default function App() {
    return (
        <Drawer ...
            closeOnOutsideClick={closeOnOutsideClick}>
        </Drawer>
    );
}

component

An alias for the template property specified in React. Accepts a custom component. Refer to Using a Custom Component for more information.

disabled

Specifies whether the UI component responds to user interaction.

Type:

Boolean

Default Value: false

elementAttr

Specifies the global attributes to be attached to the UI component's container element.

Selector: ElementAttr
Type:

Object

Default Value: {}

jQuery
$(function(){
    $("#drawerContainer").dxDrawer({
        // ...
        elementAttr: {
            id: "elementId",
            class: "class-name"
        }
    });
});
Angular
HTML
TypeScript
<dx-drawer ...
    [elementAttr]="{ id: 'elementId', class: 'class-name' }">
</dx-drawer>
import { DxDrawerModule } from "devextreme-angular";
// ...
export class AppComponent {
    // ...
}
@NgModule({
    imports: [
        // ...
        DxDrawerModule
    ],
    // ...
})
Vue
App.vue
<template>
    <DxDrawer ...
        :element-attr="drawerAttributes">
    </DxDrawer>
</template>

<script>
import DxDrawer from 'devextreme-vue/drawer';

export default {
    components: {
        DxDrawer
    },
    data() {
        return {
            drawerAttributes: {
                id: 'elementId',
                class: 'class-name'
            }
        }
    }
}
</script>
React
App.js
import React from 'react';

import Drawer from 'devextreme-react/drawer';

class App extends React.Component {
    drawerAttributes = {
        id: 'elementId',
        class: 'class-name'
    }

    render() {
        return (
            <Drawer ...
                elementAttr={this.drawerAttributes}>
            </Drawer>
        );
    }
}
export default App;

height

Specifies the view's height.

Type:

Number

|

String

|

Function

Return Value:

Number

|

String

The UI component's height.

Default Value: undefined

This property accepts a value of one of the following types:

  • Number
    The height in pixels.

  • String
    A CSS-accepted measurement of height. For example, "55px", "20vh", "inherit". If you want to specify a relative height, use vh height measurements.

  • Function (deprecated since v21.2)
    Refer to the W0017 warning description for information on how to migrate to viewport units.

hint

Specifies text for a hint that appears when a user pauses on the UI component.

Type:

String

Default Value: undefined

hoverStateEnabled

Specifies whether the UI component changes its state when a user pauses on it.

Type:

Boolean

Default Value: false

maxSize

Specifies the drawer's width or height (depending on the drawer's position) in the opened state.

Type:

Number

Default Value: null

See Also

minSize

Specifies the drawer's width or height (depending on the drawer's position) in the closed state.

Type:

Number

Default Value: null

See Also

onDisposing

A function that is executed before the UI component is disposed of.

Type:

Function

Function parameters:

Information about the event.

Object structure:
Name Type Description
model any

The model data. Available only if you use Knockout.

element

HTMLElement | jQuery

The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery.

component

Drawer

The UI component's instance.

Default Value: null

onInitialized

A function used in JavaScript frameworks to save the UI component instance.

Type:

Function

Function parameters:

Information about the event.

Object structure:
Name Type Description
element

HTMLElement | jQuery

The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery.

component

Drawer

The UI component's instance.

Default Value: null

Angular
app.component.html
app.component.ts
<dx-drawer ...
    (onInitialized)="saveInstance($event)">
</dx-drawer>
import { Component } from "@angular/core";
import Drawer from "devextreme/ui/data_grid";
// ...
export class AppComponent {
    drawerInstance: Drawer;
    saveInstance (e) {
        this.drawerInstance = e.component;
    }
}
Vue
App.vue (Options API)
App.vue (Composition API)
<template>
    <div>
        <DxDrawer ...
            @initialized="saveInstance">
        </DxDrawer>
    </div>
</template>

<script>
import DxDrawer from 'devextreme-vue/drawer';

export default {
    components: {
        DxDrawer
    },
    data: function() {
        return {
            drawerInstance: null
        };
    },
    methods: {
        saveInstance: function(e) {
            this.drawerInstance = e.component;
        }
    }
};
</script>
<template>
    <div>
        <DxDrawer ...
            @initialized="saveInstance">
        </DxDrawer>
    </div>
</template>

<script setup>
import DxDrawer from 'devextreme-vue/drawer';

let drawerInstance = null;

const saveInstance = (e) => {
    drawerInstance = e.component;
}
</script>
React
App.js
import Drawer from 'devextreme-react/drawer';

class App extends React.Component {
    constructor(props) {
        super(props);

        this.saveInstance = this.saveInstance.bind(this);
    }

    saveInstance(e) {
        this.drawerInstance = e.component;
    }

    render() {
        return (
            <div>
                <Drawer onInitialized={this.saveInstance} />
            </div>
        );
    }
}
See Also
jQuery
  • Get a UI component Instance in jQuery
Angular
  • Get a UI component Instance in Angular
Vue
  • Get a UI component Instance in Vue
React
  • Get a UI component Instance in React

onOptionChanged

A function that is executed after a UI component property is changed.

Type:

Function

Function parameters:

Information about the event.

Object structure:
Name Type Description
value any

The modified property's new value.

previousValue any

The UI component's previous value.

name

String

The modified property if it belongs to the first level. Otherwise, the first-level property it is nested into.

model any

Model data. Available only if you use Knockout.

fullName

String

The path to the modified property that includes all parent properties.

element

HTMLElement | jQuery

The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery.

component

Drawer

The UI component's instance.

Default Value: null

The following example shows how to subscribe to component property changes:

jQuery
index.js
$(function() {
    $("#drawerContainer").dxDrawer({
        // ...
        onOptionChanged: function(e) {
            if(e.name === "changedProperty") {
                // handle the property change here
            }
        }
    });
});
Angular
app.component.html
app.component.ts
app.module.ts
<dx-drawer ...
    (onOptionChanged)="handlePropertyChange($event)"> 
</dx-drawer>
import { Component } from '@angular/core'; 

@Component({ 
    selector: 'app-root', 
    templateUrl: './app.component.html', 
    styleUrls: ['./app.component.css'] 
}) 

export class AppComponent { 
    // ...
    handlePropertyChange(e) {
        if(e.name === "changedProperty") { 
            // handle the property change here
        }
    }
}
import { BrowserModule } from '@angular/platform-browser'; 
import { NgModule } from '@angular/core'; 
import { AppComponent } from './app.component'; 
import { DxDrawerModule } from 'devextreme-angular'; 

@NgModule({ 
    declarations: [ 
        AppComponent 
    ], 
    imports: [ 
        BrowserModule, 
        DxDrawerModule 
    ], 
    providers: [ ], 
    bootstrap: [AppComponent] 
}) 

export class AppModule { }  
Vue
App.vue
<template> 
    <DxDrawer ...
        @option-changed="handlePropertyChange"
    />            
</template> 

<script>  
import 'devextreme/dist/css/dx.light.css'; 
import DxDrawer from 'devextreme-vue/drawer'; 

export default { 
    components: { 
        DxDrawer
    }, 
    // ...
    methods: { 
        handlePropertyChange: function(e) {
            if(e.name === "changedProperty") {
                // handle the property change here
            }
        }
    } 
} 
</script> 
React
App.js
import React from 'react';  
import 'devextreme/dist/css/dx.light.css'; 

import Drawer from 'devextreme-react/drawer'; 

const handlePropertyChange = (e) => {
    if(e.name === "changedProperty") {
        // handle the property change here
    }
}

export default function App() { 
    return ( 
        <Drawer ...
            onOptionChanged={handlePropertyChange}
        />        
    ); 
} 

opened

Specifies whether the drawer is opened.

Type:

Boolean

Default Value: false
Raised Events: onOptionChanged

openedStateMode

Specifies how the drawer interacts with the view in the opened state.

Default Value: 'shrink'

The following modes are available:

  • "overlap"
    The drawer overlaps the view. If you assign "overlap" to the openedStateMode property, the Drawer uses the Popup component to render a side menu. A z-index of all overlay UI components (Popup, Popover, etc.) on a page is calculated when a component is created and it takes into account the z-indexes of existing overlays. As a result, a newly opened Popup (the Drawer's panel) is displayed at the top. If you need to display a different window at the top, call the focus() method for the Popup after the openedStateMode property is changed.

  • "shrink"
    The view's width decreases to accommodate the drawer.

  • "push"
    The drawer partially displaces the view.

Note that if the value of this property changes, the Drawer template is re-rendered.

View Demo

See Also

position

Specifies the drawer's position in relation to the view.

Default Value: 'left'

Use "before" and "after" if the Drawer should be positioned differently in right-to-left and regular representations. The following table shows the dependency between the rtlEnabled value and "before" and "after" positions:

"before" "after"
rtlEnabled: false left side of the view right side of the view
rtlEnabled: true right side of the view left side of the view

Top or Bottom Position Demo Left or Right Position Demo

render

An alias for the template property specified in React. Accepts a rendering function. Refer to Using a Rendering Function for more information.

revealMode

Specifies the drawer's reveal mode.

Type:

RevealMode

Default Value: 'slide'

The following modes are available:

  • "slide"
    The drawer slides in. The drawer and its content are animated.

  • "expand"
    The drawer expands from the closed position. The drawer's width is animated; its content is not.

When you change the Drawer's reveal mode, the component needs to perform recalculations for animation. As a result, the template is rerendered which can increase loading time.

View Demo

See Also

rtlEnabled

Switches the UI component to a right-to-left representation.

Type:

Boolean

Default Value: false

When this property is set to true, the UI component text flows from right to left, and the layout of elements is reversed. To switch the entire application/site to the right-to-left representation, assign true to the rtlEnabled field of the object passed to the DevExpress.config(config) method.

JavaScript
DevExpress.config({
    rtlEnabled: true
});

DataGrid Demo Navigation UI Demo Editors Demo

shading

Specifies whether to shade the view when the drawer is opened.

Type:

Boolean

Default Value: false

See Also

template

Specifies the drawer's content.

Type:

template

Template Data: undefined
Default Name: 'panel'

DevExtreme HTML5 JavaScript Drawer

This property specifies the drawer's content. To specify the view's content, nest it inside the Drawer's markup element as shown in the code below.

IMPORTANT
Always specify a fixed width for the drawer's content because this is used to calculate the drawer's width. If the drawer is positioned on the y-axis, specify a fixed height for the drawer's content because it determines the drawer's height.
jQuery
index.js
$(function() {
    $("#drawerContainer").dxDrawer({
        template: function() {
            const $drawerContent = $("<div>").width(200);
            // ...
            // Specify the drawer's content here
            // ...
            return $drawerContent;
        }
    });
});
index.html
<div id="drawerContainer">
    <!-- Declare the view's content here -->
</div>
Angular
app.component.html
<dx-drawer
    template="drawer-content">
    <div *dxTemplate="let data of 'drawer-content'" style="width:200px;">
        <!-- Declare the drawer's content here -->
    </div>
    <!-- Declare the view's content here -->
</dx-drawer>
Vue
App.vue
<template>
    <DxDrawer
        template="drawer-content">
        <template #drawer-content="{ data }" style="width:200px;">
            <!-- Declare the drawer's content here -->
        </template>
        <!-- Declare the view's content here -->
    </DxDrawer>
</template>

<script>
import 'devextreme/dist/css/dx.light.css';

import DxDrawer from 'devextreme-vue/drawer';

export default {
    components: {
        DxDrawer
    }
}
</script>
React
App.js
import React from 'react';

import 'devextreme/dist/css/dx.light.css';

import Drawer from 'devextreme-react/drawer';

function DrawerContent() {
    return (
        <div style={{ width: 200 }}>
            {/* Declare the drawer's content here */}
        </div>
    )
}

export default function App() {
    return (
        <Drawer
            render={DrawerContent}>
            {/* Declare the view's content here */}
        </Drawer>
    );
}
NOTE
The Drawer UI component is not designed to contain another Drawer. Do not use nested Drawers to avoid possible issues in your application.

View Demo

See Also

visible

Specifies whether the Drawer UI component (including the view) is visible.

Type:

Boolean

Default Value: true

width

Specifies the view's width.

Type:

Number

|

String

|

Function

Return Value:

Number

|

String

The UI component's width.

Default Value: undefined

This property accepts a value of one of the following types:

  • Number
    The width in pixels.

  • String
    A CSS-accepted measurement of width. For example, "55px", "20vw", "auto", "inherit". If you want to specify relative width, use the vw width measurements.

  • Function (deprecated since v21.2)
    Refer to the W0017 warning description for information on how you can migrate to viewport units.