DevExtreme Angular - 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.

HTML
TypeScript
  • <dx-tabs
  • [items]="tabs">
  • </dx-tabs>
  • import { DxTabsModule } from "devextreme-angular";
  • // ...
  • export class AppComponent {
  • tabs = [
  • { text: "User", icon: 'user' },
  • { text: "Comment", badge: "New" },
  • { text: "Find", disabled: true }
  • ];
  • }
  • @NgModule({
  • imports: [
  • // ...
  • DxTabsModule
  • ],
  • // ...
  • })

If you need a more flexible solution, define an itemTemplate. In Angular and Vue, you can declare it in the markup. In React, you can use a rendering function (shown in the code below) or component:

HTML
TypeScript
  • <dx-tabs
  • [items]="tabs"
  • itemTemplate="tabItem">
  • <div *dxTemplate="let itemData of 'tabItem'">
  • <p style="color:#6600cc;">{{itemData.text}}</p>
  • </div>
  • </dx-tabs>
  • import { DxTabsModule } from "devextreme-angular";
  • // ...
  • export class AppComponent {
  • tabs = [
  • { text: "User" },
  • { text: "Comment" },
  • { text: "Find" }
  • ];
  • }
  • @NgModule({
  • imports: [
  • // ...
  • DxTabsModule
  • ],
  • // ...
  • })

If you use jQuery, use DOM manipulation methods to combine the HTML markup for tabs. To apply this markup, use the itemTemplate callback function as shown in the following code:

You can also customize individual tabs. In Angular, Vue, and React, declare them using the dxItem component. When using jQuery, you can declare the tabs as scripts and reference them in the template option or assign a customization function straight to this option.

HTML
TypeScript
  • <dx-tabs>
  • <dxi-item>
  • <span>User</span>
  • </dxi-item>
  • <dxi-item>
  • <span>Comment</span>
  • </dxi-item>
  • </dx-tabs>
  • import { DxTabsModule } from "devextreme-angular";
  • // ...
  • export class AppComponent {
  • // ...
  • }
  • @NgModule({
  • imports: [
  • // ...
  • DxTabsModule
  • ],
  • // ...
  • })

In addition, you can use a 3rd-party template engine to customize widget appearance. For more information, see the 3rd-Party Template Engines article.

See Also