Angular 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.
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.
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
- ],
- // ...
- })
You can also customize individual tabs. Declare them using the dxItem component.
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
- ],
- // ...
- })