JavaScript/jQuery Tabs - Customize Item Appearance
For a minor customization of tabs, you can define specific fields in item data objects. For example, the following code generates three tabs: the first has an icon, the second has a badge, the third is disabled.
App.js
- import React from 'react';
- import 'devextreme/dist/css/dx.light.css';
- import { Tabs } from 'devextreme-react/tabs';
- const tabs = [
- { text: "User", icon: 'user' },
- { text: "Comment", badge: "New" },
- { text: "Find", disabled: true }
- ];
- class App extends React.Component {
- render() {
- return (
- <Tabs
- items={tabs}
- />
- );
- }
- }
- export default App;
If you need a more flexible solution, define an itemTemplate.
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" },
- { text: "Find" }
- ];
- const renderTabItem = (itemData) => {
- return (
- <p style={{color: '#6600cc'}}>{itemData.text}</p>
- );
- }
- class App extends React.Component {
- render() {
- return (
- <Tabs
- items={tabs}
- itemRender={renderTabItem}
- />
- );
- }
- }
- export default App;
You can also customize individual tabs. Declare them using the dxItem component.
App.js
- import React from 'react';
- import 'devextreme/dist/css/dx.light.css';
- import { Tabs, Item } from 'devextreme-react/tabs';
- class App extends React.Component {
- render() {
- return (
- <Tabs>
- <Item>
- <span>User</span>
- </Item>
- <Item>
- <span>Comment</span>
- </Item>
- </Tabs>
- );
- }
- }
- export default App;
See Also
Feel free to share topic-related thoughts here.
If you have technical questions, please create a support ticket in the DevExpress Support Center.
Thank you for the feedback!
If you have technical questions, please create a support ticket in the DevExpress Support Center.