<div class="tabs-demo">
<div class="widget-container">
<div
[class.widget-wrapper]="widgetWrapperClasses['widget-wrapper']"
[class.widget-wrapper-horizontal]="
widgetWrapperClasses['widget-wrapper-horizontal']
"
[class.widget-wrapper-vertical]="
widgetWrapperClasses['widget-wrapper-vertical']
"
[class.strict-width]="widgetWrapperClasses['strict-width']"
>
<dx-tabs
#withText
[width]="width"
[selectedIndex]="0"
[rtlEnabled]="rtlEnabled"
[scrollByContent]="scrollByContent"
[showNavButtons]="showNavButtons"
[dataSource]="tabsWithText"
[orientation]="orientation"
[stylingMode]="stylingMode"
[iconPosition]="iconPosition"
></dx-tabs>
<dx-tabs
#withIconAndText
[width]="width"
[selectedIndex]="0"
[rtlEnabled]="rtlEnabled"
[scrollByContent]="scrollByContent"
[showNavButtons]="showNavButtons"
[dataSource]="tabsWithIconAndText"
[orientation]="orientation"
[stylingMode]="stylingMode"
[iconPosition]="iconPosition"
></dx-tabs>
<dx-tabs
#withIcon
[width]="width"
[selectedIndex]="0"
[rtlEnabled]="rtlEnabled"
[scrollByContent]="scrollByContent"
[showNavButtons]="showNavButtons"
[dataSource]="tabsWithIcon"
[orientation]="orientation"
[stylingMode]="stylingMode"
[iconPosition]="iconPosition"
></dx-tabs>
</div>
</div>
<div class="options">
<div class="caption">Options</div>
<div class="option">
<span>Orientation</span>
<dx-select-box
[inputAttr]="{ 'aria-label': 'Orientation' }"
[items]="orientations"
[(value)]="orientation"
(onValueChanged)="onOrientationChanged($event)"
></dx-select-box>
</div>
<div class="option">
<span>Styling mode</span>
<dx-select-box
[inputAttr]="{ 'aria-label': 'Styling Mode' }"
[items]="stylingModes"
[(value)]="stylingMode"
></dx-select-box>
</div>
<div class="option">
<span>Icon position</span>
<dx-select-box
[inputAttr]="{ 'aria-label': 'Icon Position' }"
[items]="iconPositions"
[(value)]="iconPosition"
></dx-select-box>
</div>
<div class="option">
<dx-check-box
id="show-navigation-buttons"
text="Show navigation buttons"
[(value)]="showNavButtons"
(onValueChanged)="toggleStrictWidthClass()"
></dx-check-box>
</div>
<div class="option">
<dx-check-box
text="Scroll content"
[(value)]="scrollByContent"
(onValueChanged)="toggleStrictWidthClass()"
></dx-check-box>
</div>
<div class="option">
<dx-check-box
text="Full width"
[value]="false"
(onValueChanged)="onFullWidthChanged($event)"
></dx-check-box>
</div>
<div class="option">
<dx-check-box
text="Right-to-left mode"
[(value)]="rtlEnabled"
></dx-check-box>
</div>
</div>
</div>
import { bootstrapApplication } from '@angular/platform-browser';
import { Component, enableProdMode, ViewChild, provideZoneChangeDetection } from '@angular/core';
import { DxSelectBoxModule, DxSelectBoxTypes } from 'devextreme-angular/ui/select-box';
import { DxCheckBoxModule, DxCheckBoxTypes } from 'devextreme-angular/ui/check-box';
import { DxTabsModule, DxTabsComponent, DxTabsTypes } from 'devextreme-angular/ui/tabs';
import { Tab, Service } from './app.service';
if (!/localhost/.test(document.location.host)) {
enableProdMode();
}
@Component({
selector: 'demo-app',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
providers: [Service],
imports: [
DxTabsModule,
DxCheckBoxModule,
DxSelectBoxModule,
],
})
export class AppComponent {
@ViewChild('withText') withText: DxTabsComponent;
@ViewChild('withIconAndText') withIconAndText: DxTabsComponent;
@ViewChild('withIcon') withIcon: DxTabsComponent;
tabsWithText: Tab[];
tabsWithIconAndText: Tab[];
tabsWithIcon: Tab[];
showNavButtons = false;
scrollByContent = false;
rtlEnabled = false;
orientations: DxTabsTypes.Orientation[] = ['horizontal', 'vertical'];
stylingModes: DxTabsTypes.TabsStyle[] = ['primary', 'secondary'];
iconPositions: DxTabsTypes.TabsIconPosition[] = ['top', 'start', 'end', 'bottom'];
width = 'auto';
orientation = this.orientations[0];
stylingMode = this.stylingModes[1];
iconPosition = this.iconPositions[0];
widgetWrapperClasses = {
'widget-wrapper': true,
'widget-wrapper-horizontal': true,
'widget-wrapper-vertical': false,
'strict-width': false,
};
constructor(service: Service) {
this.tabsWithText = service.getTabsWithText();
this.tabsWithIconAndText = service.getTabsWithIconAndText();
this.tabsWithIcon = service.getTabsWithIcon();
}
onOrientationChanged(e: DxSelectBoxTypes.ValueChangedEvent) {
if (e.value === 'vertical') {
this.widgetWrapperClasses['widget-wrapper-vertical'] = true;
this.widgetWrapperClasses['widget-wrapper-horizontal'] = false;
} else {
this.widgetWrapperClasses['widget-wrapper-horizontal'] = true;
this.widgetWrapperClasses['widget-wrapper-vertical'] = false;
}
}
toggleStrictWidthClass() {
this.widgetWrapperClasses['strict-width'] = this.scrollByContent || this.showNavButtons;
}
onFullWidthChanged(e: DxCheckBoxTypes.ValueChangedEvent) {
this.width = e.value ? '100%' : 'auto';
}
}
bootstrapApplication(AppComponent, {
providers: [
provideZoneChangeDetection({ eventCoalescing: true, runCoalescing: true }),
],
});
::ng-deep .tabs-demo {
display: flex;
}
::ng-deep .strict-width {
max-width: 340px;
}
::ng-deep .dx-theme-generic .strict-width {
max-width: 250px;
}
::ng-deep .widget-container {
display: flex;
align-items: center;
justify-content: center;
flex-grow: 1;
width: 100%;
min-width: 200px;
padding: 16px 32px;
overflow: clip;
}
::ng-deep .widget-wrapper {
display: inline-flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 80px;
width: 100%;
}
::ng-deep .widget-wrapper-vertical {
width: 100%;
flex-direction: row;
align-items: center;
}
.options {
display: flex;
flex-direction: column;
flex-shrink: 0;
padding: 20px;
background-color: rgba(191, 191, 191, 0.15);
}
.caption {
font-weight: 500;
font-size: 18px;
}
::ng-deep #show-navigation-buttons {
margin-top: 22px;
}
.option {
margin-top: 20px;
}
::ng-deep .dx-tabs {
max-width: 100%;
}
::ng-deep .dx-tabs-vertical {
height: 216px;
}
::ng-deep .dx-viewport:not(.dx-theme-generic) .dx-tabs-horizontal {
border-block-end: 1px solid rgb(225, 225, 225, 0.4);
}
::ng-deep .dx-viewport:not(.dx-theme-generic) .dx-tabs-vertical {
height: 232px;
border-inline-end: 1px solid rgb(225, 225, 225, 0.4);
}
import { Injectable } from '@angular/core';
export class Tab {
id: number;
text?: string;
icon?: string;
}
const tabsWithText: Tab[] = [
{
id: 0,
text: 'User',
},
{
id: 1,
text: 'Analytics',
},
{
id: 2,
text: 'Clients',
},
{
id: 3,
text: 'Orders',
},
{
id: 4,
text: 'Favorites',
},
{
id: 5,
text: 'Search',
},
];
const tabsWithIcon: Tab[] = [
{
id: 0,
icon: 'user',
},
{
id: 1,
icon: 'chart',
},
{
id: 2,
icon: 'accountbox',
},
{
id: 3,
icon: 'ordersbox',
},
{
id: 4,
icon: 'bookmark',
},
{
id: 5,
icon: 'search',
},
];
const tabsWithIconAndText: Tab[] = [
{
id: 0,
text: 'User',
icon: 'user',
},
{
id: 1,
text: 'Analytics',
icon: 'chart',
},
{
id: 2,
text: 'Clients',
icon: 'accountbox',
},
{
id: 3,
text: 'Orders',
icon: 'ordersbox',
},
{
id: 4,
text: 'Favorites',
icon: 'bookmark',
},
{
id: 5,
text: 'Search',
icon: 'search',
},
];
@Injectable()
export class Service {
getTabsWithText(): Tab[] {
return tabsWithText;
}
getTabsWithIconAndText(): Tab[] {
return tabsWithIconAndText;
}
getTabsWithIcon(): Tab[] {
return tabsWithIcon;
}
}
<!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>