All docs
V21.1
24.1
The page you are viewing does not exist in version 24.1.
23.2
The page you are viewing does not exist in version 23.2.
23.1
The page you are viewing does not exist in version 23.1.
22.2
22.1
21.2
21.1
20.2
20.1
19.2
The page you are viewing does not exist in version 19.2.
19.1
The page you are viewing does not exist in version 19.1.
18.2
The page you are viewing does not exist in version 18.2.
18.1
The page you are viewing does not exist in version 18.1.
17.2
The page you are viewing does not exist in version 17.2.
A newer version of this page is available. Switch to the current version.

jQuery Tabs - Control the Behavior

An end user can select Tabs items in two different modes: 'single' (by default) or 'multiple'. You can use the selectionMode property to change the mode.

jQuery
JavaScript
$(function() {
    $("#tabsContainer").dxTabs({
        items: [
            { text: "User" },
            { text: "Comment" },
            // ...
        ],
        selectionMode: "multiple"
    });
});
Angular
HTML
TypeScript
<dx-tabs
    [items]="tabs"
    selectionMode="multiple">
</dx-tabs>
import { DxTabsModule } from "devextreme-angular";
// ...
export class AppComponent {
    tabs = [
        { text: "User" },
        { text: "Comment" },
        // ...
    ];
}
@NgModule({
    imports: [
        // ...
        DxTabsModule
    ],
    // ...
})
Vue
App.vue
<template>
    <DxTabs
        :items="tabs"
        selection-mode="multiple" /> 
</template>
<script>
import 'devextreme/dist/css/dx.light.css';

import DxTabs from "devextreme-vue/tabs";

export default {
    components: {
        DxTabs
    },
    data() {
        return {
            tabs: [
                { text: "User" },
                { text: "Comment" },
                // ...
            ]
        };
    }
};
</script>
React
App.js
import React from 'react';
import 'devextreme/dist/css/dx.light.css';

import { Tabs } from 'devextreme-react/tabs';

const tabs = [
    { text: "User" },
    { text: "Comment" },
    // ...
];

class App extends React.Component {
    render() {
        return (
            <Tabs
                items={tabs}
                selectionMode="multiple"
            />
        );
    }
}

export default App;

If you need a tab to be preselected or to select it programmatically, pass its index in the data source array to the selectedIndex property.

jQuery
JavaScript
$(function() {
    $("#tabsContainer").dxTabs({
        items: [
            { text: "User" },
            { text: "Comment" },
            // ...
        ],
        selectedIndex: 1
    });
});
Angular
HTML
TypeScript
<dx-tabs
    [items]="tabs"
    [(selectedIndex)]="selectedIndex">
</dx-tabs>
import { DxTabsModule } from "devextreme-angular";
// ...
export class AppComponent {
    selectedIndex: number;

    tabs = [
        { text: "User" },
        { text: "Comment" },
        // ...
    ];

    constructor() {
        this.selectedIndex = 1;
    }
}
@NgModule({
    imports: [
        // ...
        DxTabsModule
    ],
    // ...
})
Vue
App.vue
<template>
    <DxTabs
        :items="tabs"
        v-model:selected-index="selectedIndex" /> 
</template>
<script>
import 'devextreme/dist/css/dx.light.css';

import DxTabs from "devextreme-vue/tabs";

export default {
    components: {
        DxTabs
    },
    data() {
        return {
            selectedIndex: 1,
            tabs: [
                { text: "User" },
                { text: "Comment" },
                // ...
            ]
        };
    }
};
</script>
React
App.js
import React from 'react';
import 'devextreme/dist/css/dx.light.css';

import { Tabs } from 'devextreme-react/tabs';

const tabs = [
    { text: "User" },
    { text: "Comment" },
    // ...
];

class App extends React.Component {
    constructor() {
        this.state = {
            selectedIndex: 1
        }
    }

    handleOptionChange = (e) => {
        if(e.fullName === 'selectedIndex') {
            this.setState({
                selectedIndex: e.value
            });
        }
    }

    render() {
        return (
            <Tabs
                items={tabs}
                selectedIndex={this.state.selectedIndex}
                onOptionChanged={this.handleOptionChange}
            />
        );
    }
}

export default App;

As an alternative, you can use the selectedItem (for "single" selectionMode) or selectedItems (for "multiple" selectionMode) properties.

jQuery
JavaScript
var tabs = [
    { text: "User" },
    { text: "Comment" },
    // ...
];

$(function() {
    $("#tabsContainer").dxTabs({
        items: tabs,
        selectionMode: 'multiple',
        selectedItems: [ tabs[0], tabs[1] ]
    });
});
Angular
HTML
TypeScript
<dx-tabs
    [items]="tabs"
    selectionMode="multiple"
    [(selectedItems)]="selectedItems">
</dx-tabs>
import { DxTabsModule } from "devextreme-angular";
// ...
export class AppComponent {
    tabs = [
        { text: "User" },
        { text: "Comment" },
        // ...
    ];

    constructor() {
        this.selectedItems = [this.tabs[0], this.tabs[1]];
    }
}
@NgModule({
    imports: [
        // ...
        DxTabsModule
    ],
    // ...
})
Vue
App.vue
<template>
    <DxTabs
        :items="tabs"
        selection-mode="multiple"
        v-model:selected-items="selectedItems" /> 
</template>
<script>
import 'devextreme/dist/css/dx.light.css';

import DxTabs from "devextreme-vue/tabs";

const tabs = [
    { text: "User" },
    { text: "Comment" },
    // ...
];

export default {
    components: {
        DxTabs
    },
    data() {
        return {
            tabs: tabs,
            selectedItems: [tabs[0], tabs[1]]
        };
    }
};
</script>
React
App.js
import React from 'react';
import 'devextreme/dist/css/dx.light.css';

import { Tabs } from 'devextreme-react/tabs';

const tabs = [
    { text: "User" },
    { text: "Comment" },
    // ...
];

class App extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            selectedItems: [tabs[0], tabs[1]];
        }
    }

    handleOptionChange = (e) => {
        if(e.fullName === 'selectedItems') {
            this.setState({
                selectedItems: e.value
            });
        }
    }

    render() {
        return (
            <Tabs
                items={tabs}
                selectionMode="multiple"
                selectedItems={this.state.selectedItems}
                onOptionChanged={this.handleOptionChange}
            />
        );
    }
}

export default App;

When the total length of all tabs exceeds the Tabs container, the UI component shows navigation buttons that help an end user scroll the tab strip. This behavior is default only for desktops. To enable it on all types of devices, assign true to the showNavButtons property. Otherwise, assign false.

jQuery
JavaScript
$(function() {
    $("#tabsContainer").dxTabs({
        items: [
            { text: "User" },
            { text: "Comment" },
            // ...
        ],
        showNavButtons: true
    });
});
Angular
HTML
TypeScript
<dx-tabs
    [items]="tabs"
    [showNavButtons]="true">
</dx-tabs>
import { DxTabsModule } from "devextreme-angular";
// ...
export class AppComponent {
    tabs = [
        { text: "User" },
        { text: "Comment" },
        // ...
    ];
}
@NgModule({
    imports: [
        // ...
        DxTabsModule
    ],
    // ...
})
Vue
App.vue
<template>
    <DxTabs
        :items="tabs"
        :show-nav-buttons="true" /> 
</template>
<script>
import 'devextreme/dist/css/dx.light.css';

import DxTabs from "devextreme-vue/tabs";

export default {
    components: {
        DxTabs
    },
    data() {
        return {
            tabs: [
                { text: "User" },
                { text: "Comment" },
                // ...
            ]
        };
    }
};
</script>
React
App.js
import React from 'react';
import 'devextreme/dist/css/dx.light.css';

import { Tabs } from 'devextreme-react/tabs';

const tabs = [
    { text: "User" },
    { text: "Comment" },
    // ...
];

class App extends React.Component {
    render() {
        return (
            <Tabs
                items={tabs}
                showNavButtons={true}
            />
        );
    }
}

export default App;
See Also