ResponsiveBox

The ResponsiveBox widget allows you to create an application or a website with a layout adapted to different screen sizes.

Included in: dx.mobile.js, dx.web.js, dx.viz-web.js, dx.all.js
Type:

Object

You can create the widget using one of the following approaches.

  • jQuery
    Use the dxResponsiveBox jQuery plug-in.

    HTML
    <div id="responsiveBox">
        <div class="header" data-options="dxItem: { 
            location: [
                { row: 0, col: 0, colspan: 3, screen: 'lg'},
                { row: 0, col: 0, colspan: 2, screen: 'xs sm md'}
            ]
        }"> . . . </div>
        <div class="content" data-options="dxItem: { 
            location: [
                { row: 1, col: 1, screen: 'lg' },
                { row: 1, col: 0, colspan: 2, screen: 'xs sm md' }
            ]
        }"> . . . </div>
        <div class="left-side-bar" data-options="dxItem: { 
            location: [
                { row: 1, col: 0, screen: 'lg' },
                { row: 2, col: 0, screen: 'xs sm md' }
            ]
        }"> . . . </div>
        <div class="right-side-bar" data-options="dxItem: { 
            location: [
                { row: 1, col: 2, screen: 'lg' },
                { row: 2, col: 1, screen: 'xs sm md' }
            ]
        }"> . . . </div>  
        <div class="footer" data-options="dxItem: {
            location: [
                { row: 2, col: 0, colspan: 3, screen: 'lg' },
                { row: 3, col: 0, colspan: 2, screen: 'xs sm md' }
            ]
        }"> . . . </div>
    </div>
    JavaScript
    $("#responsiveBox").dxResponsiveBox({
        singleColumnScreen: 'xs',
        rows: [
            { ratio: 1 },
            { ratio: 2 },
            { ratio: 2, screen: 'sm md' },
            { ratio: 1 }
        ],
        cols: [
            { ratio: 1 },
            { ratio: 2, screen: 'lg' },
            { ratio: 1 }
        ]
    });
  • Knockout
    Add a div element and apply the dxResponsiveBox binding to this element.

    HTML
    <div class="box" data-bind="dxResponsiveBox: {
        singleColumnScreen: 'xs',
        rows: [
            { ratio: 1 },
            { ratio: 2 },
            { ratio: 2, screen: 'sm md' },
            { ratio: 1 }
        ],
        cols: [
            { ratio: 1 },
            { ratio: 2, screen: 'lg' },
            { ratio: 1 }
        ]
    }">
        <div class="header" data-options="dxItem: { 
            location: [
                { row: 0, col: 0, colspan: 3, screen: 'lg'},
                { row: 0, col: 0, colspan: 2, screen: 'xs sm md'}
            ]
        }"></div>
        <div class="content" data-options="dxItem: { 
            location: [
                { row: 1, col: 1, screen: 'lg' },
                { row: 1, col: 0, colspan: 2, screen: 'xs sm md' }
            ]
        }"></div>
        <div class="left-side-bar" data-options="dxItem: { 
            location: [
                { row: 1, col: 0, screen: 'lg' },
                { row: 2, col: 0, screen: 'xs sm md' }
            ]
        }"></div>
        <div class="right-side-bar" data-options="dxItem: { 
            location: [
                { row: 1, col: 2, screen: 'lg' },
                { row: 2, col: 1, screen: 'xs sm md' }
            ]
        }"></div>  
        <div class="footer" data-options="dxItem: {
            location: [
                { row: 2, col: 0, colspan: 3, screen: 'lg' },
                { row: 3, col: 0, colspan: 2, screen: 'xs sm md' }
            ]
        }"></div>
    </div>
  • AngularJS
    Add a div element and apply the dx-responsive-box directive to this element.

    HTML
    <div dx-responsive-box="{
        singleColumnScreen: 'xs',
        rows: [
            { ratio: 1 },
            { ratio: 2 },
            { ratio: 2, screen: 'sm md' },
            { ratio: 1 }
        ],
        cols: [
            { ratio: 1 },
            { ratio: 2, screen: 'lg' },
            { ratio: 1 }
        ]
    }">
        <div class="header" data-options="dxItem: { 
            location: [
                { row: 0, col: 0, colspan: 3, screen: 'lg'},
                { row: 0, col: 0, colspan: 2, screen: 'xs sm md'}
            ]
        }"></div>
        <div class="content" data-options="dxItem: { 
            location: [
                { row: 1, col: 1, screen: 'lg' },
                { row: 1, col: 0, colspan: 2, screen: 'xs sm md' }
            ]
        }"></div>
        <div class="left-side-bar" data-options="dxItem: { 
            location: [
                { row: 1, col: 0, screen: 'lg' },
                { row: 2, col: 0, screen: 'xs sm md' }
            ]
        }"></div>
        <div class="right-side-bar" data-options="dxItem: { 
            location: [
                { row: 1, col: 2, screen: 'lg' },
                { row: 2, col: 1, screen: 'xs sm md' }
            ]
        }"></div>  
        <div class="footer" data-options="dxItem: {
            location: [
                { row: 2, col: 0, colspan: 3, screen: 'lg' },
                { row: 3, col: 0, colspan: 2, screen: 'xs sm md' }
            ]
        }"></div>
    </div>

Note that DevExtreme widgets require you to link the jQuery library to your application. If you use the Knockout or AngularJS approach, the Knockout or AngularJS library is also required. For detailed information on linking these libraries to your project, refer to the Installation article.

Refer to the Layout Widgets guide for more information on working with the Box widget.

View Demo

Watch Video

Show Example:
AngularJS
Knockout
jQuery

Configuration

An object defining configuration options for the widget.

Methods

This section describes members used to manipulate the widget.

Events

This section describes events fired by this widget.

Default Item Template

This section lists the fields that are used in a default template for widget items.

By default, a predefined item template is applied to display the items of this widget. This template is based on certain fields of the data source provided for this widget. Below is the list of these fields. If the default item template is not appropriate for your task, implement a custom item template based on these or other fields of your data source.

See Also