UI Widgets Tabs

A tab strip used to switch between pages.

Included in: dx.phonejs.js, dx.webappjs.js, dx.all.js

The dxTabs widget displays items that perform an action when clicked.

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

  • jQuery
    Use the dxTabs jQuery plug-in.

    HTML
    <div id="tabs"></div>
    JavaScript
    var tabItems = [
        { text: "Home", icon: "home" },
        { text: "About", icon: "info" }
    ]
    $("#tabs").dxTabs({
        dataSource: tabItems
    });
  • Knockout
    Add a div element and apply the dxTabs binding to this element.

    HTML
    <div data-bind="dxTabs: {
        dataSource: tabItems
    }"></div>
  • Angular
    Add a div element and apply the dx-tabs directive to this element.

    HTML
    <div dx-tabs="{
        dataSource: tabItems
    }"></div>

Note that DevExtreme widgets require you to link the jQuery and Globalize libraries to your application. If you use the Knockout or Angular approach, the Knockout or Angular library is also required.

See Also

Since the dxTabs widget is used to display multiple items, it supports common the Collection Container widget functionality. You can find detailed information on the principles of working with the widget in the dxTabs section of the Collection Container Widgets article.

View Demo

Show Example:
AngularJS
Knockout
jQuery
<div ng-controller="demoController">
    <div dx-tabs="{
        dataSource: tabs,
        bindingOptions: {
            selectedIndex: 'selectedTab'
        }
    }"></div>
    <div class="tabContent">{{tabContent()}}</div>
</div>
var myApp = angular.module('myApp', ['dx']);
myApp.controller("demoController", function ($scope) {
    $scope.tabs = [
        { text: "user", icon: "user", content: "'User' tab content" },
        { text: "comment", icon: "comment", content: "'Comment' tab content" },
        { text: "find", icon: "find", content: "'Find' tab content" }
    ];
    $scope.tabContent = function(){
        return $scope.tabs[$scope.selectedTab].content;
    };
    $scope.selectedTab = 0;
});
angular.element(document).ready(function () {
    angular.bootstrap(document, ['myApp']);
});
body {
    text-align: center;
}
.tabContent {
    padding: 20px;
    height: 200px;
    margin: 20px;
    border: 1px solid;
}
<div data-bind="dxTabs: {
    dataSource: tabs,
    selectedIndex: selectedTab
}"></div>
<div class="tabContent" data-bind="text: tabContent"></div>
var myViewModel = function() {
    this.tabs = [
        { text: "user", icon: "user", content: "'User' tab content" },
        { text: "comment", icon: "comment", content: "'Comment' tab content" },
        { text: "find", icon: "find", content: "'Find' tab content" }
    ];
    this.selectedTab = ko.observable(0);
    this.tabContent = ko.computed(function () {
        return this.tabs[this.selectedTab()].content;
    }, this);
}
ko.applyBindings(new myViewModel());
body {
    text-align: center;
}
.tabContent {
    padding: 20px;
    height: 200px;
    margin: 20px;
    border: 1px solid;
}
<div id="myTabs"></div>
<div class="tabContent" id="myTabContent">'User' tab content</div>
$("#myTabs").dxTabs({
    dataSource: [
        { text: "User", icon: "user", content: "'User' tab content" },
        { text: "Comment", icon: "comment", content: "'Comment' tab content" },
        { text: "Find", icon: "find", content: "'Find' tab content" }
    ],
    selectedIndex: 0,
    onItemClick: function (e) {
        $("#myTabContent").text(e.itemData.content);
    }
});
body {
    text-align: center;
}
.tabContent {
    padding: 20px;
    height: 200px;
    margin: 20px;
    border: 1px solid;
}

Configuration

An object defining configuration options for the dxTabs widget.

Methods

This section describes members used to manipulate the widget.

Events

This section describes events exposed by this widget.

Default Item Template

This section lists the data source fields that are used in a default template for tabs.

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 a 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