Your search did not match any results.
Tabs

Tabs

Documentation

The Tabs is a tab strip used to switch between pages or views.

Copy to CodeSandBox
Apply
Reset
import React from 'react'; import Tabs from 'devextreme-react/tabs'; import SelectBox from 'devextreme-react/select-box'; import { tabs, longtabs } from './data.js'; class App extends React.Component { constructor() { super(); this.state = { selectedIndex: 0 }; this.onValueChanged = this.onValueChanged.bind(this); this.onTabsSelectionChanged = this.onTabsSelectionChanged.bind(this); } render() { const { selectedIndex } = this.state; return ( <React.Fragment> <div id={'longtabs'}> <div className={'caption'}>Tabs</div> <Tabs dataSource={longtabs} /> </div> <div id={'scrolledtabs'}> <div className={'caption'}>Tabs with Overflow</div> <Tabs dataSource={longtabs} width={300} scrollByContent={true} showNavButtons={true} /> </div> <div id={'tabs'}> <div className={'caption'}>API</div> <Tabs dataSource={tabs} selectedIndex={selectedIndex} onOptionChanged={this.onTabsSelectionChanged} /> <div className={'content dx-fieldset'}> <div className={'dx-field'}> <div className={'dx-field-label'}>Selected index:</div> <div className={'dx-field-value'}> <SelectBox dataSource={tabs} displayExpr={'text'} valueExpr={'id'} value={selectedIndex} onValueChanged={this.onValueChanged} /> </div> </div> <div className={'dx-field'}> <div className={'dx-field-label'}>Selected content:</div> <div className={'dx-field-value-static left-aligned'}> {tabs[selectedIndex].content} </div> </div> </div> </div> </React.Fragment> ); } onTabsSelectionChanged(args) { if(args.name == 'selectedIndex') { this.setState({ selectedIndex: args.value }); } } onValueChanged(args) { this.setState({ selectedIndex: args.value }); } } export default App;
import React from 'react'; import ReactDOM from 'react-dom'; import App from './App.js'; ReactDOM.render( <App />, document.getElementById('app') );
<!DOCTYPE html> <html> <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=1.0" /> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/19.1.5/css/dx.common.css" /> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/19.1.5/css/dx.light.css" /> <link rel="stylesheet" type="text/css" href="styles.css" /> <script src="https://unpkg.com/core-js@2.4.1/client/shim.min.js"></script> <script src="https://unpkg.com/systemjs@0.21.3/dist/system.js"></script> <script type="text/javascript" src="config.js"></script> <script type="text/javascript"> System.import('./index.js'); </script> </head> <body class="dx-viewport"> <div class="demo-container"> <div id="app"></div> </div> </body> </html>
.content{ text-align: justify; margin-top: 25px; } #longtabs{ margin-top: 20px; } #scrolledtabs { margin-top: 20px; } #tabs { margin-top: 60px; } .caption{ font-size: 16px; padding-bottom: 3px; padding-left: 10px; } .left-aligned { text-align: left; }
export const tabs = [ { id: 0, text: 'user', icon: 'user', content: 'User tab content' }, { id: 1, text: 'comment', icon: 'comment', content: 'Comment tab content' }, { id: 2, text: 'find', icon: 'find', content: 'Find tab content' } ]; export const longtabs = [ { text: 'user' }, { text: 'analytics' }, { text: 'customers' }, { text: 'search' }, { text: 'favorites' }, { text: 'additional' }, { text: 'clients' }, { text: 'orders' }, { text: 'shipment' } ];
System.config({ transpiler: 'plugin-babel', paths: { 'npm:': 'https://unpkg.com/' }, defaultExtension: 'js', map: { 'react': 'npm:react@16/umd/react.development.js', 'react-dom': 'npm:react-dom@16/umd/react-dom.development.js', 'prop-types': 'npm:prop-types/prop-types.js', 'devextreme': 'npm:devextreme@19.1', 'devextreme-react': 'npm:devextreme-react@19.1', 'jszip': 'npm:jszip@3.1.3/dist/jszip.min.js', 'quill': 'npm:quill@1.3.6/dist/quill.js', 'devexpress-diagram': 'npm:devexpress-diagram', // SystemJS plugins 'plugin-babel': 'npm:systemjs-plugin-babel@0/plugin-babel.js', 'systemjs-babel-build': 'npm:systemjs-plugin-babel@0/systemjs-babel-browser.js' }, packages: { 'devextreme': { defaultExtension: 'js' }, 'devextreme-react': { main: 'index.js' } }, babelOptions: { sourceMaps: false, stage0: true, react: true } });