DevExtreme v26.1 is now available.

Explore our newest features/capabilities and share your thoughts with us.

Your search did not match any results.

Angular Responsive Box

The ResponsiveBox component allows you to create an application or a website with a layout adapted to different screen sizes. In this demo, each element on the page is a ResponsiveBox element whose location is specified for each possible screen size.

Backend API
<div id="page"> <dx-responsive-box singleColumnScreen="sm" [(screenByWidth)]="screen"> <dxi-responsive-box-row [ratio]="1"></dxi-responsive-box-row> <dxi-responsive-box-row [ratio]="2"></dxi-responsive-box-row> <dxi-responsive-box-row [ratio]="1"></dxi-responsive-box-row> <dxi-responsive-box-col [ratio]="1"></dxi-responsive-box-col> <dxi-responsive-box-col [ratio]="2" screen="lg"></dxi-responsive-box-col> <dxi-responsive-box-col [ratio]="1"></dxi-responsive-box-col> <dxi-responsive-box-item> <dxi-responsive-box-location [row]="0" [col]="0" [colspan]="3" screen="lg" ></dxi-responsive-box-location> <dxi-responsive-box-location [row]="0" [col]="0" [colspan]="2" screen="sm" ></dxi-responsive-box-location> <div *dxTemplate class="header item"> <p>Header</p> </div> </dxi-responsive-box-item> <dxi-responsive-box-item> <dxi-responsive-box-location [row]="1" [col]="1" screen="lg" ></dxi-responsive-box-location> <dxi-responsive-box-location [row]="1" [col]="0" [colspan]="2" screen="sm" ></dxi-responsive-box-location> <div *dxTemplate class="content item"> <p>Content</p> </div> </dxi-responsive-box-item> <dxi-responsive-box-item> <dxi-responsive-box-location [row]="1" [col]="0" screen="lg" ></dxi-responsive-box-location> <dxi-responsive-box-location [row]="2" [col]="0" screen="sm" ></dxi-responsive-box-location> <div *dxTemplate class="left-side-bar item"> <p>Left Bar</p> </div> </dxi-responsive-box-item> <dxi-responsive-box-item> <dxi-responsive-box-location [row]="1" [col]="2" screen="lg" ></dxi-responsive-box-location> <dxi-responsive-box-location [row]="2" [col]="1" screen="sm" ></dxi-responsive-box-location> <div *dxTemplate class="right-side-bar item"> <p>Right Bar</p> </div> </dxi-responsive-box-item> <dxi-responsive-box-item> <dxi-responsive-box-location [row]="2" [col]="0" [colspan]="3" screen="lg" ></dxi-responsive-box-location> <dxi-responsive-box-location [row]="3" [col]="0" [colspan]="2" screen="sm" ></dxi-responsive-box-location> <div *dxTemplate class="footer item"> <p>Footer</p> </div> </dxi-responsive-box-item> </dx-responsive-box> </div>
import { bootstrapApplication } from '@angular/platform-browser'; import { Component, enableProdMode, provideZoneChangeDetection } from '@angular/core'; import { DxResponsiveBoxModule } from 'devextreme-angular'; if (!/localhost/.test(document.location.host)) { enableProdMode(); } @Component({ selector: 'demo-app', templateUrl: './app.component.html', styleUrls: ['./app.component.css'], imports: [ DxResponsiveBoxModule, ], }) export class AppComponent { screen(width) { return (width < 700) ? 'sm' : 'lg'; } } bootstrapApplication(AppComponent, { providers: [ provideZoneChangeDetection({ eventCoalescing: true, runCoalescing: true }), ], });
::ng-deep .demo-container, #page { height: 100%; min-height: 300px; } ::ng-deep #page .header { background-color: #C6B1DE; text-align: center; } ::ng-deep #page .content { background-color: #EDBBE7; } ::ng-deep #page .left-side-bar { background-color: #F9E2AE; } ::ng-deep #page .right-side-bar { background-color: #9FD89F; } ::ng-deep #page .footer { background-color: #B4D6FA; } ::ng-deep .item { height: 100%; } ::ng-deep #page p { font-size: 20px; padding-top: 10px; text-align: center; color: #000; }
<!DOCTYPE html> <html lang="en"> <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=5.0" /> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/26.1.5/css/dx.light.css" /> </head> <body class="dx-viewport"> <div class="demo-container"> <demo-app>Loading...</demo-app> </div> <script src="https://cdn.jsdelivr.net/npm/zone.js@0.16.2/bundles/zone.umd.js"></script> <script src="./bundle.js" type="module"></script> </body> </html>